Skip to main content

Web SDK Installation

The Alogame Web SDK integrates Alogame login into a browser-based HTML5 (H5) game.

Scope — login + portal launcher

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 is not the Egret/Cocos bridge

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

Distributionnpm (ESM / CJS) or a single UMD <script>
Runtime depsNone — pure TypeScript/JS, ~10 KB gzipped
BrowsersChrome 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:

index.html
<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
main.ts
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

FieldTypeRequiredDescription
gameIdstring | numberYour game id, issued by Alogame
baseUrlstringAlogame 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)
floatingButtonbooleanAuto-show the floating launcher after login (default true)
appVersionstringYour 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.

ValueUsed inNotes
game_idOEGWebSdk.init() (client)Identifies your game
No browser secret

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:

➡️ /web-sdk-demo.html

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().

Next step

Authentication