Web SDK Installation
The Alogame Web SDK integrates Alogame login into a browser-based HTML5 (H5) game.
The game's main job is authentication. Once the player is logged in, the SDK shows a floating button that handles top-up, account info, change password, and logout by redirecting to the Alogame portals.
If your game has its own top-up button, call OEGPayment.openPaymentPage() (or sdk.openPaymentPage()) from that button. The SDK uses the CMS payment_url and attaches the player's session via SSO. See Authentication and Floating Button.
This SDK (@alogame/web-sdk) is for H5 games that run directly in the browser and talk to Alogame over REST. If your game compiles to a native Android/iOS app (Cocos Creator, Egret), use alogame-sdk instead — a different package with a different transport.
Requirements
| Distribution | npm (ESM / CJS) or a single UMD <script> |
| Runtime deps | None — pure TypeScript/JS, ~10 KB gzipped |
| Browsers | Chrome 90+ · Firefox 88+ · Safari 14+ · Edge 90+ |
Option A — <script> tag (UMD)
The fastest way to drop the SDK into any H5 game, no build step required:
<script src="https://cdn.alogame.vn/web-sdk/1.0.7/oeg-web-sdk.min.js"></script>
<script>
// Everything is exposed under the global `window.OEGWebSdk`
const { OEGWebSdk, OEGAuth } = window.OEGWebSdk;
OEGWebSdk.init({
gameId: 38, // your game id (number or string)
baseUrl: 'https://api-sdk.oeg.vn', // OEG SDK backend
language: 'vi', // 'vi' | 'en'
floatingButton: true // default true — SDK handles portal redirects
});
</script>
This is a versioned CDN URL. It can be cached long-term; future SDK releases should publish under a new version path, for example
/web-sdk/1.0.1/....
Option B — npm
npm install @alogame/web-sdk
import { OEGWebSdk, OEGAuth, OEGPayment } from '@alogame/web-sdk';
const sdk = await OEGWebSdk.init({
gameId: 38,
baseUrl: 'https://api-sdk.oeg.vn',
language: 'vi',
floatingButton: true, // default true — SDK handles portal redirects
});
The package ships full TypeScript declarations — AuthUser, AuthResult,
SdkConfig, and the rest are all importable from @alogame/web-sdk.
Initialize the SDK
Call OEGWebSdk.init() once when your game boots. It is a singleton —
repeat calls return the same instance.
const sdk = await OEGWebSdk.init({
gameId: 38,
baseUrl: 'https://api-sdk.oeg.vn',
language: 'vi',
floatingButton: true, // default true — see Floating Button page
});
SdkConfig
| Field | Type | Required | Description |
|---|---|---|---|
gameId | string | number | ✅ | Your game id, issued by Alogame |
baseUrl | string | ✅ | Alogame SDK backend. Prod: https://api-sdk.oeg.vn · Dev: https://dev-api-sdk.oeg.vn |
language | 'vi' | 'en' | — | UI language for the built-in modals (default vi) |
floatingButton | boolean | — | Auto-show the floating launcher after login (default true) |
appVersion | string | — | Your game's build version, attached to analytics events as app_version. Prefer this over relying on the CMS config version — only the game knows its own build. |
On init() the SDK fetches per-game config from the backend (feature flags,
enabled login providers, payment_url and profile portal URLs) and restores any saved
session, so a returning player stays logged in across reloads.
Required game information
Contact your Alogame Operation Manager to obtain your game_id.
| Value | Used in | Notes |
|---|---|---|
game_id | OEGWebSdk.init() (client) | Identifies your game |
OEGWebSdk.init() does not take a secretKey. Do not put any server secret,
webhook secret, or signing key in browser code.
Try the live demo
A runnable end-to-end demo (game 38) is hosted here:
View its source for a complete, minimal integration. Note that the demo loads a copy of
the SDK bundled with this docs site (./oeg-web-sdk.min.js), not the version-pinned CDN URL
shown above — so it can lag the current release. Use the CDN URL in your own game. Beyond
that, the demo does nothing more than init() + open the login screen. The SDK floating
button handles the default top-up/account actions, and the demo also shows how a
game-owned button can call OEGPayment.openPaymentPage().