Godot
Use ZokoGames from Godot 4 Web exports with the zokogames addon, its autoload, signals and callback or await style GDScript API.
The zokogames addon (packages/sdk-engines/godot/addons/zokogames) targets Godot 4 Web exports (the addon loads in Godot 4.0 or newer, but a build that runs on the portal needs Godot 4.3 or newer, see Thread Support below; Godot 3 has its own addon with the same API, see Godot 3 below). It registers one autoload, ZokoGames, that talks to the JavaScript SDK through a small bridge (window.ZokoBridge) defined in the export's HTML shell. Outside a browser (in the editor, or a desktop run) a built-in simulator answers instead, so the same code runs everywhere. Terms such as "midgame" and "rewarded" are in the glossary.
Status (1.7.0): run in the official Godot 4.3 and 4.7.2 editors and as Web exports in a real browser (2026-11-23). The addon imports with no errors or warnings, enabling the plugin registers the autoload, every public method and signal behaves as documented in simulator mode, and the Web export (4.3, Thread Support off) contains the bridge. Godot 4.0 to 4.2 were not run. Send the Godot version and the exact error to support if the first import fails.
Install#
Download the Godot plugin: /sdk-engines/zokogames-godot-1.7.0.zip (the same files as the folder in the repository).
/sdk-engines/godot.zip is always the latest version. Checksums: /sdk-engines/SHA256SUMS. Index of every engine package with its version, size and SHA-256: /sdk-engines/engines.json.
- Copy
addons/zokogamesinto your project'sres://addons/folder. It holdsplugin.cfg,plugin.gd,zokogames.gd(the autoload),zoko_banner.gdandexport/zokogames_shell.html. - Project > Project Settings > Plugins: enable ZokoGames. This registers the autoload
ZokoGames(res://addons/zokogames/zokogames.gd) and thezokogames/simulator/*settings. - Project > Export: add a Web preset and set Custom HTML Shell to
res://addons/zokogames/export/zokogames_shell.html. The shell loadshttps://sdk.zokogames.com/zokogames-sdk-v1.jsbefore the engine, createswindow.ZokoBridge, and reports the engine download to the portal's loading bar. With your own shell, add the script tag to<head>and copy the bridge block from the supplied one. await ZokoGames.init_async()once at startup, before any other call.- Optional: add a
ZokoBannernode (zoko_banner.gd) over the space you can spare for a banner. Theexamples/folder next to the addon haszoko_demo.gd(keys A, R, G, H, U, F, T, S, B) andzoko_store.gd.
Without the custom shell window.ZokoBridge does not exist. The addon logs a warning and falls back to the simulator, so the game runs but uses no real ads, users or saves.
Godot 3#
Godot 3.x (3.5 and 3.6 LTS are the targets, 3.3 and 3.4 should work) has its own addon with the same public API as the Godot 4 one: the same autoload ZokoGames, the same method names and the same signals, so a project can move between them. Download it: /sdk-engines/zokogames-godot3-1.7.1.zip. It is written in GDScript 1 and calls the SDK through the JavaScript singleton.
Status (1.7.1): run in the official Godot 3.6.3 editor and as an HTML5 Web export in a real browser (2026-11-23). The addon imports with no errors or warnings (warnings treated as errors), enabling the plugin registers the autoload, every public method and signal behaves as documented in simulator mode, and the HTML5 export contains the bridge. Version 1.7.1 fixed the simulator rejecting an empty encrypted score. Godot 3.3 to 3.5 are not verified. Send the Godot version and the exact error to support if the first import fails.
Install:
- Copy
addons/zokogamesfrom the download into your project'sres://addons/folder and enable ZokoGames under Project > Project Settings > Plugins. This registers the autoloadZokoGames. - Project > Export: add an HTML5 preset and set Custom HTML Shell to
res://addons/zokogames/export/zokogames_shell.html. It loads the same SDK script as the Godot 4 shell. Leave GDNative off, and use the Adaptive canvas resize policy. - Start with
yield(ZokoGames.init_async(), "completed").
What differs from the Godot 4 addon:
| Godot 4 | Godot 3 |
|---|---|
await ZokoGames.get_user_async() |
yield(ZokoGames.get_user_async(), "completed"), which returns the same Dictionary |
callback: Callable |
callback: a FuncRef, funcref(self, "_on_done") |
ZokoGames.ad_started.connect(f) |
ZokoGames.connect("ad_started", self, "_on_ad_started") |
The addon pauses the tree and mutes the Master bus while an ad plays, restores both, and applies the portal's mute setting to Master (pause_game_during_ads, mute_audio_during_ads, follow_portal_mute, all true by default) |
The same properties and defaults |
JavaScriptBridge |
JavaScript |
On Godot 4 the Godot 3 addon refuses to start (init() fails with unsupportedEngine). The full table and the export settings are in the addon README.
Which path#
| You are | Do this |
|---|---|
| A Godot hobbyist with a finished game | Copy the addon, enable it, set the shell, add the snippet below, export with threads off, upload. |
| A hobbyist starting out | Same, and test every call in the editor first: the simulator needs no browser. |
A working script#
Put this in a script on a node in your first scene (or in your own autoload). It covers init, a midgame ad, a rewarded ad, gameplay start and stop, save and load, and a leaderboard score.
extends Node
func _ready() -> void:
var res := await ZokoGames.init_async()
if not res.ok:
push_warning("ZokoGames unavailable: %s" % res.error.code)
# The addon pauses the tree and mutes Master during an ad, and follows the portal's mute setting
# (pause_game_during_ads, mute_audio_during_ads, follow_portal_mute): no ad or mute handlers needed.
var level := int(ZokoGames.data_get_item("level", "1")) # load: synchronous Strings
start_game(level)
# Call when the player takes control, and when play stops.
func on_play_start() -> void:
if ZokoGames.is_available():
ZokoGames.gameplay_start()
func on_play_stop() -> void:
if ZokoGames.is_available():
ZokoGames.gameplay_stop()
func show_midgame() -> void:
var res := await ZokoGames.request_ad_async("midgame") # completes after the ad is over
if not res.ok:
print("no ad: ", res.error.code) # adCooldown, unfilled, adblock ...
func on_reward_button() -> void:
var res := await ZokoGames.request_ad_async("rewarded")
if res.ok:
grant_reward() # reward only after the ad finished
func save_progress(level: int) -> void:
var r := ZokoGames.data_set_item("level", str(level)) # synchronous, uploaded in the background
if not r.ok:
push_warning(r.error.code) # for example dataLimitExceeded
func submit_score(score: float) -> void:
var user := await ZokoGames.get_user_async()
if not user.ok or user.result == null:
return # guests are not ranked
var r := await ZokoGames.submit_score_async("", score) # "" works only on a board WITHOUT an encryption key
if not r.ok:
print(r.error.code)
func start_game(_level: int) -> void: pass
func grant_reward() -> void: passThe addon pauses the tree from ad_started until ad_finished or ad_error, mutes the Master bus meanwhile, and applies the portal's mute setting to Master after init and on every change (pause_game_during_ads, mute_audio_during_ads and follow_portal_mute on the ZokoGames autoload, all true; set one to false to handle that part yourself). The autoload runs with PROCESS_MODE_ALWAYS, so its signals still arrive while the tree is paused; nodes of your own that must react during an ad need the Always process mode.
About the leaderboard: a board with an encryption key counts only a correctly encrypted payload (leaderboards), and no engine wrapper ships an encryption helper, so "" works only for a board without a key. For a keyed board, encrypt yourself (AES-256-GCM, additional data zoko-score-v1|<userId>|<gameId>; the player id is user.result.__dangerousUserId from get_user_async) or compute the score on your server and use the server API.
How calls work#
GDScript names are snake_case. Every method that talks to the portal comes in two forms:
| Form | Example | Use it for |
|---|---|---|
| Callback | ZokoGames.get_user(callback) |
Fire-and-forget calls. The Callable is optional and last, except in store_get_catalog_items(callback, limit, offset) and store_get_player_inventory(callback, limit, offset), where it comes first, and in get_user_token(signing_key_type, callback). |
| Awaitable | await ZokoGames.get_user_async() |
Straight-line code. The name ends in _async. |
Both deliver a Dictionary, { "ok": true, "result": <value> } or { "ok": false, "error": { "code": "...", "message": "..." } } (request_ad takes a Dictionary of callables instead). All methods live directly on the autoload; there are no ad., game. or user. sub-objects.
| JavaScript | GDScript |
|---|---|
SDK.init() |
await ZokoGames.init_async() or ZokoGames.init(callback); signal initialized(ok) |
SDK.environment |
ZokoGames.environment ("local", "zokogames" or "disabled"), ZokoGames.is_available(), ZokoGames.is_simulated, ZokoGames.is_qa_tool, ZokoGames.VERSION |
SDK.ad.requestAd(type, cbs) |
ZokoGames.request_ad(type, {"ad_started": f, "ad_finished": f, "ad_error": f}) or await ZokoGames.request_ad_async(type) |
SDK.ad.hasAdblock() |
ZokoGames.has_adblock(callback) or await ZokoGames.has_adblock_async() |
SDK.banner.requestBanner(...) |
await ZokoGames.request_banner_async(id, width, height, window_rect) |
SDK.banner.requestResponsiveBanner(id) |
await ZokoGames.request_responsive_banner_async(id, window_rect) |
SDK.banner.clearBanner(id) / clearAllBanners() |
ZokoGames.clear_banner(id) / ZokoGames.clear_all_banners() |
SDK.game.gameplayStart() / gameplayStop() |
ZokoGames.gameplay_start() / ZokoGames.gameplay_stop() |
SDK.game.loadingStart() / loadingStop() / loadingProgress(n) |
ZokoGames.loading_start() / loading_stop() / loading_progress(n) |
SDK.game.happytime() |
ZokoGames.happytime() |
SDK.game.reportGameCompletedPercentage(n) |
ZokoGames.report_game_completed_percentage(n) |
SDK.game.setGameContext(obj) / clearGameContext() |
ZokoGames.set_game_context(dict) / ZokoGames.clear_game_context() |
SDK.game.updateRoom(u) / leftRoom() |
ZokoGames.update_room(dict) / ZokoGames.left_room() |
SDK.game.inviteLink(p) / getInviteParam(k) |
await ZokoGames.invite_link_async(dict) / ZokoGames.get_invite_param(key) |
SDK.game.showInviteButton(p) / hideInviteButton() |
await ZokoGames.show_invite_button_async(dict) / ZokoGames.hide_invite_button() |
SDK.game.settings |
ZokoGames.settings (disableChat, muteAudio), signal settings_changed |
SDK.game.isOffline, offline listener |
ZokoGames.is_offline, signal offline_changed(offline) |
SDK.game.isInstantMultiplayer / inviteParams |
ZokoGames.is_instant_multiplayer (alias is_instant_join) / ZokoGames.invite_params, signal join_room(params) |
SDK.user.isUserAccountAvailable / systemInfo |
ZokoGames.is_user_account_available / ZokoGames.system_info |
SDK.user.getUser() |
await ZokoGames.get_user_async() |
SDK.user.getUserToken(opts) |
await ZokoGames.get_user_token_async(signing_key_type) |
SDK.user.showAuthPrompt() |
await ZokoGames.show_auth_prompt_async(), signal auth_changed(user) |
SDK.user.showAccountLinkPrompt() |
await ZokoGames.show_account_link_prompt_async() |
SDK.user.listFriends(opts) |
await ZokoGames.list_friends_async(page, size) |
SDK.user.submitScore(opts) |
await ZokoGames.submit_score_async(encrypted_score, score) |
SDK.data.getItem(k) / setItem(k, v) |
ZokoGames.data_get_item(key, default) / ZokoGames.data_set_item(key, value); also data_has_key, data_remove_item, data_clear (all synchronous) |
SDK.store.* |
store_get_catalog_items_async, store_get_player_inventory_async, store_buy_item_async(item_id), store_consume_item_async(sku, qty), store_get_purchase_token_async(), is_store_available, store_set_sandbox(bool) (synchronous); signals purchase_completed(item_id), purchase_failed(error) |
SDK.achievements.list() / unlock(key) / onUnlock |
await ZokoGames.achievements_list_async() / achievements_unlock_async(key), signal achievement_unlocked(achievement); see achievements |
SDK.analytics.trackOrder(p, o) |
await ZokoGames.track_order_async(provider, order) |
SDK.analytics.track(name, params) (1.7.0) |
ZokoGames.track(name, params) / track_async(name, params) |
Signals on the autoload: initialized, ad_started, ad_finished, ad_error(error), auth_changed, settings_changed, offline_changed, join_room, purchase_completed, purchase_failed. Error codes are in ZokoGames.ERROR_CODES (a Dictionary keyed by module, for example ZokoGames.ERROR_CODES.ad); ZokoGames.has_error_code(res, "purchaseCancelled") tests a result.
Kids mode. Since version 1.5.0 the wrapper exposes it: ZokoGames.settings.get("kidsMode", false) is true when the game runs in kids mode (a game with the kids flag, or a player in kids mode); hide chat, rooms, sign-in prompts and shop screens then. A portal that does not send the field gives false, so also keep honouring ZokoGames.settings.disableChat, which the portal sets to true in the same cases. To test it, switch on zokogames/simulator/kids_mode in the simulator (it also turns chat off, as the portal does). See kids mode.
Room data channel#
Added in SDK 1.3.0. The room data channel lets the players of one room exchange small JSON messages and share a tiny state that only the host writes, so a simple multiplayer game needs no server of its own. It is for game data, not text chat. It exists after updateRoom (or after joining from an invite) and ends with leftRoom, needs a signed-in player and a portal with realtime enabled (otherwise roomUnavailable), and has these limits: 8 KB per message or patch, 20 messages per second, 64 KB of state, state keys of 1 to 40 characters of A-Z a-z 0-9 _ . : -. Messages are never echoed back to their sender on the portal; the first player in the room is the host. The full rules and error codes (notInRoom, notHost, payloadTooLarge, stateTooLarge, unknownMember, rateLimited, roomUnavailable) are in the game module and the multiplayer guide.
The autoload carries it as room_* methods and signals. Payloads cross the bridge as JSON: use Dictionary, Array, String, numbers, bool and null (numbers come back as float). Outside a browser the simulator is one room with one member that receives its own messages and state changes.
| JavaScript | Godot |
|---|---|
room.send(data, { to }) |
ZokoGames.room_send(data, to, cb) / room_send_async(data, to) / room_send_to(member_id, data, cb) |
room.onMessage(cb) |
signal room_message(message) (from, data, direct, seq, ts) |
room.setState(patch) |
room_set_state(patch, cb) / room_set_state_async(patch) (a null value removes the key) |
room.getState(), room.onState(cb) |
room_get_state(), room_get_state_value(key, default); signal room_state(state, change) |
room.members(), room.onMembers(cb) |
room_get_members(); signal room_members(members) |
room.isHost(), room.onHostChange(cb), room.selfId |
room_is_host(); signal room_host_changed(host_id, is_host); room_self_id() |
room.addLeftListener(cb) (1.7.0) |
signal room_left(reason, room_id) |
room.onError(cb) |
signal room_error(error) |
func _ready() -> void:
await ZokoGames.init_async()
ZokoGames.room_message.connect(func(m: Dictionary) -> void: print(m.from, " played ", m.data))
ZokoGames.room_host_changed.connect(_on_host_changed)
await ZokoGames.update_room_async({"roomId": "match-1", "isJoinable": true})
func _on_host_changed(_host_id: String, is_host: bool) -> void:
if is_host:
ZokoGames.room_set_state({"turn": "X"})
func play_cell(cell: int) -> void:
await ZokoGames.room_send_async({"cell": cell, "mark": "X"})Banners#
Banner rectangles are in window pixels. Drop a ZokoBanner node (a Control) where the banner should go; it reports its on-screen rectangle (accounting for stretch mode), requests on _ready, and clears itself when it leaves the tree.
| Property | Meaning |
|---|---|
container_id |
Banner id, default zoko-banner. |
size_mode |
responsive (largest size that fits) or one of 728x90, 300x250, 320x50, 468x60, 320x100. |
request_on_ready |
Request automatically in _ready. |
show_simulator_placeholder |
Draw a placeholder rectangle while the simulator answers. |
By hand: await ZokoGames.request_responsive_banner_async("menu", $BannerSlot.get_global_rect()). Request banners on menu screens only.
Purchases#
func buy_first_item() -> void:
if not ZokoGames.is_store_available:
return
var catalog := await ZokoGames.store_get_catalog_items_async()
if not catalog.ok or catalog.result.is_empty():
return
var bought := await ZokoGames.store_buy_item_async(catalog.result[0].sku)
if ZokoGames.has_error_code(bought, "purchaseCancelled"):
return
var token := await ZokoGames.store_get_purchase_token_async() # send to your server and verify thereVerify ownership on your server (see in-game purchases). examples/zoko_store.gd is the full flow.
Web export settings that matter#
- Custom HTML Shell:
res://addons/zokogames/export/zokogames_shell.html, as above. Canvas sizing is done by the shell (the canvas fills the frame,widthandheight100 percent), so use a Stretch Mode ofcanvas_itemswith aspectexpandorkeepin Project Settings > Display > Window > Stretch. - Thread Support: off. Threaded exports need
SharedArrayBuffer, which needs cross-origin isolation (COOP and COEP headers). Game pages are served without them, so a threaded build cannot start (symptom:SharedArrayBuffer is not definedor a blank canvas). Use the single-threaded web export: in Godot 4.3 and later untick Thread Support in the Web preset. Godot 4.0 to 4.2 have no such option (their web exports always useSharedArrayBuffer), so they cannot run on the portal; export from 4.3 or newer. Extensions Support: off unless you need it. - File names. Export to a file named
index.html(type that name in the export path): the portal needsindex.htmlat the archive root, and the export names its other files after it:index.js,index.wasm,index.pckand the audio worklet scripts. Do not rename them to.bror.gz: the engine requests the plain names. The game origin serves a file ending in.bror.gzwith the matchingContent-Encodingheader, but it does that by suffix, so it only helps an engine that asks for exactly those names (Unity does; Godot does not). The portal does not document transfer compression of plain files, and the initial-download estimate uses uncompressed sizes: keep the.wasmand.pcksmall. - Texture compression. In the export preset enable VRAM compression for both desktop (S3TC/BPTC) and mobile (ETC2/ASTC) so every browser has a format.
- Size. Use a custom export template with unused modules disabled and keep the
.pcksmall. Limits: 1,500 files, 250 MB unpacked, about 50 MB initial download (20 MB for mobile). Export With Debug: off. - Memory. Mobile browsers have a small heap; avoid loading every level's textures up front, and stream with
ResourceLoader.load_threaded_requestafter the first scene (thread-pool loading still works in a non-threaded export). Cap resolution on phones, see mobile. - Audio unlock. Browsers keep audio suspended until the first click or key press. Godot starts its audio after the first input; show a "click to play" screen and start music from that input, not in
_ready. - Fullscreen. Use the fullscreen button in the portal's frame bar, which fullscreens the whole frame. The frame is allowed to go fullscreen, so
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)works, but it fullscreens your canvas only; do not add a competing button. - Loading. The shell already reports the engine download and calls
loadingStopwhen the engine has started. For a longer in-game loading screen callZokoGames.loading_start(),loading_progress(percent)andloading_stop()yourself.
Upload: Project > Export > Web > Export Project, zip the folder contents so index.html is at the archive root, upload it in the developer console, and run the Preview tool first.
Ad rules#
There are no prerolls: your game cannot request an ad before it starts. Midgame is the only interstitial type, so an interstitial or commercial break from another platform becomes a midgame ad (request_ad("midgame")); the only other type is rewarded. In local mode (testing on localhost, outside the portal) a midgame request fails with ad_error with adCooldown until your game has called ZokoGames.gameplay_start() or 30 seconds of visible page time have passed. On the portal the first midgame ad needs ZokoGames.gameplay_start() first as well, so call it when the player takes control (a game that never calls it gets midgame ads 30 seconds after play begins). Rewarded ads are not held back by this. Details: ads reference and ads guide.
Test locally#
- In the editor or a desktop run
ZokoGames.is_simulatedis true. Tune the simulator under Project Settings > zokogames/simulator:ad_behaviour(fill,no_fill,error),ad_duration_seconds(default 1.5),adblock,disabled,account_available,logged_in,username,user_id,friend_count,mute_audio,disable_chat,offline,store_availableandverbose. Cloud save is inuser://zoko_sim_data.json, the simulated inventory inuser://zoko_sim_inventory.json. - Difference to remember. The simulator does not enforce the three-minute midgame cooldown (
adCooldown) that the portal and the browser's local mode do. - A Web export on
localhost. Serve the export folder from a local web server onlocalhost(openingindex.htmlfrom disk does not work for WebAssembly). The bridge exists, sois_simulatedis false and the JavaScript SDK runs its own local mode: a three-second ad overlay, fake players,localStoragesaves,?sdk_debug=true,?ad_response=unfilled. - Then open the Preview tool with your local address and watch the checklist tick.
Known pitfalls#
sdkNotLoaded. The page has no SDK script tag; use the custom shell.ZokoGamesautoload missing. The plugin is not enabled.- Calls fail with
sdkNotInitialized.await ZokoGames.init_async()first. - Works in the editor, not in the browser. Open the browser console and check that
window.ZokoBridgeexists (the shell defines it). - Game stays paused after an ad. Resume on
ad_erroras well asad_finished. Do not useCONNECT_ONE_SHOTonad_started: when an ad fails (unfilled,adCooldown,adblock),ad_startednever fires and the one-shot connection stays armed for the next ad. - Banners never show. The
ZokoBannernode needs a size and must be visible. - Threaded export will not start. Turn Thread Support off.
After an ad, a sign-in or account-link prompt or a checkout, keyboard focus goes back to the game frame and its canvas by itself, so the player's keys work again without a click.
Chat reports, screenshots and storage mirror#
Since SDK 1.4.0: ZokoGames.report_chat({"reportedName": "Trixie", "message": "buy gold", "reason": "spam"}, callback) (or report_chat_async), ZokoGames.set_screenshot_provider(callable) (a viewport capture after frame_post_draw is registered by default) and ZokoGames.mirror_local_storage({"prefix": "save_"}) with the mirror_error signal. Godot's own user:// files live in IndexedDB, not localStorage, so the mirror does not see them; save those with data_set_item. The editor simulator accepts all three. Godot 3 has the same functions in its addon.
Next#
- Check your build against the build validation rules and the launch checklist.
- Upload and publish: submission walkthrough.
- Other engines and shared rules: engines overview.