Environments and query overrides
SDK.environment is a string you can read after init() resolves. It is "disabled" until then.
| Value | Meaning |
|---|---|
zokogames |
The game is inside the portal's iframe (the live site, the Preview tool or the build preview in the console). All features are real. |
local |
The in-page mock described in local testing. |
disabled |
Neither of the above. Every SDK module member (methods reject, properties throw) fails with sdkDisabled. Only init(), environment and isQaTool keep working. You see it, for example, when you open your build's own address directly or frame the game on your own site. |
How the SDK decides#
- If the page is the top-level window (not in an iframe), it is
localwhen the host islocalhost,127.0.0.1,[::1]or*.localhost, or when the URL hasuseLocalSdk=true. Otherwise it isdisabled. - If the page is in an iframe, the SDK sends a handshake to the parent and waits up to 1.5 seconds for the portal to answer. When the parent page is the portal itself (
httpsonzokogames.com), it waits up to 15 seconds. A valid answer giveszokogames. Only an answer from a ZokoGames page (httpsonzokogames.comor one of its subdomains, except the game hostsg-<slug>and the preview runnerpreview-run), a local host (only while the game itself runs on a local host) or the game's own origin counts: an answer from any other site is ignored, so a site that frames your game cannot pose as the portal. If nothing answers, the SDK falls back tolocalwhen local mode is allowed by the rules above, and todisabledotherwise.
The practical consequence: a game uploaded to a random web host does not get a mock unless you add ?useLocalSdk=true, which is deliberate. A game that ships its own copy of itself elsewhere keeps working, it just does not talk to the portal.
await SDK.init();
switch (SDK.environment) {
case "zokogames": break; // production behaviour
case "local": showDevBadge(); break; // your machine
case "disabled": hidePortalFeatures(); break;
}Query parameters the SDK reads#
| Parameter | Where it applies | Purpose |
|---|---|---|
useLocalSdk=true |
Any host | Allows local mode off localhost. |
sdk_debug=true |
Everywhere | Logs every call. Turn it on to diagnose a problem in the preview tool. |
qaTool=true |
Everywhere | Makes SDK.isQaTool true. |
ad_response=... |
Local mode only | Forces ad requests to fail with the given code. |
Mock switches (disableChat, muteAudio, user_response and so on) |
Local mode only | Listed in local testing. |
In the portal these parameters are ignored for anything except logging. Players cannot change their identity or ad behaviour by editing the URL.
Initialisation errors#
init() itself never rejects. Failures show up as disabled. After that:
- Calling a method before
init()resolved rejects (or throws, for synchronous members) withsdkNotInitialized. - Calling it while disabled gives
sdkDisabled.
See errors for the full list.