跳到主要内容

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.

<script type="module">
import { VLPlaySDK } from 'https://lib.vlplay.vn/sdk/latest/vlplay.esm.js';
// continue with Step 2 here
</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);
}

Next: Full Web SDK Installation Guide