Quick Start: Web SDK
Integrate VLPlay SDK into your web game in minutes. The Web SDK is distributed as a hosted JavaScript bundle via CDN at https://lib.vlplay.vn. It works with any JavaScript framework — React, Vue, plain HTML, or Phaser.js.
Once included, call VLPlaySDK.init() once when your game loads. The SDK will handle token storage, session management, and communication with VLPlay servers automatically.
Step 1: Include the SDK
Add the VLPlay SDK script to your HTML before your game code. Your CDN access token will be provided by your VLPlay representative.
- ES Module (recommended)
- UMD / Global
<script type="module">
import { VLPlaySDK } from 'https://lib.vlplay.vn/sdk/latest/vlplay.esm.js';
// continue with Step 2 here
</script>
<!-- Adds window.VLPlaySDK -->
<script src="https://lib.vlplay.vn/sdk/latest/vlplay.min.js"></script>
Step 2: Initialize
await VLPlaySDK.init({
appId: 'YOUR_APP_ID',
clientSecret: 'YOUR_CLIENT_SECRET',
env: 'production', // or 'sandbox'
});
console.log('VLPlay SDK ready:', VLPlaySDK.version);
Step 3: Trigger Login
const result = await VLPlaySDK.auth.login();
if (result.success) {
console.log('Logged in as:', result.user.displayName);
}