Skip to content
Docs pages

Developers

Bring your HTML5 game to Leono Games

How your HTML5 game runs on Leono Games, how it talks to the portal, and what you need to do to integrate it.

On this page

Leono Games is a mobile-first portal for HTML5 games that play instantly in the browser. Players jump in with a guest account, compete on daily, weekly and all-time leaderboards, and watch ads between rounds or in exchange for in-game rewards. These docs are for studios and developers who want to bring their games to the portal: how to use the SDK, what a game must do, how to test it, and how to submit and release it.

You don't need to know what the portal is built with. Your game only has to be a static bundle (HTML, JS, assets) that loads one SDK file and calls a few functions at the right moments.

How a game runs on the portal

  • A separate origin for games. Your bundle is served from the games origin https://games.leonogames.com, separate from the portal origin https://leonogames.com. Every version lives at a fixed path, /<slug>/<version>/.
  • The iframe is created only when the player hits Play. The portal first creates a play session for the player, then builds an <iframe> pointing to your index.html with the query ?wsg=1&host=<portal origin>&lang=<vi|en>&v=<version>.
  • The SDK is the bridge. Your game loads /sdk/v1/wsg-sdk.js, which also lives on the games origin. When you call WSG.init(), the SDK reads that query, performs a handshake with the portal page over postMessage, and from then on every feature (player, scores, leaderboards, ads, saved data, sharing) goes through that channel.
  • Games never call the portal API. The portal page receives requests from your game, calls the API on its behalf and sends the result back. The player cookie, the play session and the anti-cheat rules all stay on the portal side; your game never sees or manages them.
  • It runs anywhere. Open your game directly, outside the portal iframe, and the SDK switches to standalone mode: every API still returns valid results, backed by localStorage. You can build and test the game without the portal.
Diagram
Player's browser
│
├─ Portal page (https://leonogames.com)
│    ├─ calls the portal API: sessions, scores, leaderboards, saved data
│    ├─ shows the loading, pause and ad overlays
│    └─ <iframe sandbox> → https://games.leonogames.com/<slug>/<version>/index.html?wsg=1&host=…
│              │
│              │  two-way postMessage, each side checks the other's origin
│              ▼
└─ Your game (games origin)
     ├─ index.html, JS, assets — loaded with relative paths
     └─ <script src="/sdk/v1/wsg-sdk.js"> → window.WSG

What you need to do

  1. Load the SDK and initialize it. Add the script tag and call await WSG.init({ gameId }). See Quick start.
  2. Report the lifecycle. Call WSG.loadingFinished() when the game is ready (that is when the portal removes its loading overlay), WSG.gameplayStart() when the player takes control and WSG.gameplayStop() when the round ends.
  3. Submit scores. Call WSG.leaderboard.submit(score) at the end of a round and declare sensible limits in game.json, because the server uses them to reject cheated scores. See Scores and leaderboards.
  4. Listen to the portal. Stop your loop and mute audio on the pause and audio(false) events, and continue on resume. Show ads at sensible moments. See Ads.
  5. Package and submit. The bundle needs index.html at its root, relative paths, and no requests to other origins. Test it in standalone mode, then send a submission with game.json, thumbnail.png and your build folder. See Game requirements and Submitting and publishing.

Things worth knowing early

  • Scores only count inside gameplay. The server accepts a score while gameplay is running or within 10 seconds after gameplayStop(), and checks it against your game's limits: maximum score, minimum play time and maximum scoring rate.
  • Scores are non-negative integers. Fractions and negative numbers are rejected with the reason invalid_score.
  • The games origin is shared by every game. localStorage, IndexedDB and cookies on it are visible to other games, so don't keep important data there. Use WSG.storage, which is stored per player and per game.
  • The iframe is sandboxed. It cannot open popups, navigate the parent page, or show alert() or confirm().
  • SDK updates need no rebuild. The SDK file lives under a major-version path (/sdk/v1/). Within a major version the SDK stays backward compatible and the portal rolls out fixes for you.

Docs pages

Addresses for this environment

Addresses in these docs are filled in for the environment you are reading them on:

ComponentAddress
Portal (website)https://leonogames.com
Games originhttps://games.leonogames.com
SDK filehttps://games.leonogames.com/sdk/v1/wsg-sdk.js
Portal APIhttps://api.leonogames.com
JWT public keys (JWKS)https://api.leonogames.com/.well-known/jwks.json