Skip to contentGo to cookie choices

The SDK in ten minutes

Load the ZokoGames SDK, start it, report gameplay, save progress and handle an ad break, with code you can run in local mode.

By ZokoGames team2 min read

A glowing plug clicking into a game controller, with a stopwatch nearby

The ZokoGames SDK is a small browser library that connects your game to the portal page that embeds it. This is the short tour. The SDK reference covers every module and method.

1. Load it#

HTML
<script src="https://sdk.zokogames.com/zokogames-sdk-v1.js"></script>
<script>
  const SDK = window.ZokoGames.SDK;
</script>

If you use a bundler, keep the script tag and read the global. The script URL carries the major version, v1.

2. Initialise#

JavaScript
await SDK.init();
if (SDK.environment === "disabled") return runStandalone();

init() never rejects. It resolves once the SDK has chosen an environment: zokogames inside the portal, local on your own machine, or disabled. Every other member needs init() to have resolved first.

3. Say when the player is playing#

JavaScript
await SDK.game.gameplayStart();
// ... pause menu, death or result screen:
await SDK.game.gameplayStop();

The portal uses this pair to measure real playtime, which feeds your basic launch metrics. Basic launch only needs gameplayStart; full launch needs both.

4. Save progress#

SDK.data mirrors localStorage, but the save follows a signed-in player across devices.

JavaScript
const level = Number(SDK.data.getItem("level") ?? "1");

function onLevelComplete(next) {
  SDK.data.setItem("level", String(next));
}

The four methods are synchronous because the whole save is loaded when init() resolves. Writes sync to the portal in the background. Values are strings, so use JSON.stringify for structured state.

5. Handle an ad break#

JavaScript
async function showMidgame() {
  await SDK.ad.requestAd("midgame", {
    adStarted: () => pauseAll(),
    adFinished: () => {},
    adError: () => {},
  });
  resumeAll();
}

Pause and mute in adStarted, and resume whether the ad finished or failed. An ad can fail for ordinary reasons: ads are off during basic launch and for kids games, a player may use an ad blocker, and midgame ads are paced. Write your handler so an unknown code takes the safe path and the game carries on.

6. Test it#

  • Local mode. Open your game from localhost and the SDK answers from an in-page mock. Ads show a short placeholder overlay, so you can test every callback. Add ?sdk_debug=true to log every call.
  • Preview tool. Open /preview to run your game inside the real portal frame with a live requirements checklist and an event log.

Next: local testing, the SDK playground and the launch checklist.

Share this post
  • 3 min read

    ZokoGames is open for developers

    ZokoGames is a web game portal. If you build HTML5 games, here is what the platform does for you, what it asks in return and where to start.

    • Platform
    • Developers
  • 3 min read

    How revenue share and statements work

    What earns revenue on ZokoGames, how a monthly statement is calculated, and what is and is not live yet.

    • Developers
    • Revenue

Back to the blog