Skip to content
InstaPlay
SDK documentation sections

Local mode and the portal emulator

SDK modes

Mode When Behaviour
instaplay the game is inside the portal (or the emulator) the real portal bridge
local localhost or ?instaplay_local=1 saves in localStorage, leaderboards in memory, player Local Player, verbose log
disabled any other site the same without the log, one console warning

Emulator: instaplay dev

npx instaplay dev ./build --port 4300

The emulator opens a portal at http://localhost:4300 and embeds the game from another origin (http://game.localhost:4301) — exactly like the real portal. The SDK is served at /_ip/sdk/v1.js, headers (CSP) are those of the games domain. The emulator panel: player A/B, guest or account (nickname and avatar preset), pause, sound, language ru/en, "offline", latency, limits, viewers for saves, leaderboards and the call log, the player token mode ("issued", "unavailable", "expired") and the player country for init (country, SDK 1.2). State lives in .instaplay/dev-state.json.

  • Switching the player in the panel (A/B, guest/account) works like signing in or out in another portal tab: the game gets the playerChanging event with a reason (A → B — switch, guest → account — login, account → guest — logout), its requests answer session_expired until the restart, and the game restarts after 1.5 s. This is how you test your "flush to my server" handler.
  • The game network from instaplay.json goes into the emulator CSP exactly as on the games domain, by the moderation rules; a local game server (http://localhost:8080) needs the --allow-local-network flag; the emulator does not register Service Workers.
  • --https — the emulator over https with a self-signed certificate: protocol-relative game addresses (//api.example.com) behave as on the portal. Without it CSP violations are printed to the terminal.
  • The SDK may be included with a tag or loaded from engine code — the emulator also counts an init call as included.
  • --url http://localhost:5173/ — the game from a dev server (Vite or similar) instead of a build folder, with hot reload.
  • The emulator signs player tokens with its own dev key: JWKS — /_emu/jwks.json on the emulator portal origin, aud — --game-id or dev:<game slug>. How to verify the token on your server — Player token for your server.
  • Ads (SDK 1.3): the emulator shows test ads — a full-screen “Test ad” placeholder and the “Watch an ad for a reward?” card; the game gets pause { reason: 'ad' } and mute. The “Ads” panel section: fill (an ad, no ad, an error, a timeout), the video length, “allow closing early”, the always/auto card, client/s2s verification, limits (none or as on the portal) and an impression log. Rewards are signed with the same dev key, aud — reward: plus the player token aud (ads, reward verification).
  • Sign-in from the game (SDK 1.4): player.login() works in the emulator too — it opens a “Sign-in from the game” window with “Sign in as a test player” and “Cancel” buttons. “Sign in” makes the player an account in place: the outcome is signed_in with the same player.id, the game goes on without a restart, the next token has kind: account; “Cancel” gives cancelled. While the window is open the game gets pause { reason: 'overlay' } and resume; a call without a player gesture is gesture_required, as on the portal. A sign-in to another account with a restart is tested by switching the player in the panel (player).

Autotest: instaplay test

npx instaplay test ./build --json --profiles desktop,mobile

Headless Chromium on top of the emulator checks: init ≤ 10 s, ready ≤ 20 s, no errors, no requests outside the game origin, a non-blank frame, gameplay.start after input. --script smoke.mjs — your scenario (for example, play and verify saves.set and leaderboard.submit). The autotest applies the game network by the production rules; a local game server in network needs --allow-local-network, as in dev (an E01 “will not pass on the portal” warning).

Before publishing: instaplay check

instaplay check ./game validates the metadata, leaderboards, build size and rules, and that the SDK is included. All of it runs locally except one step: the category and tags are checked against the portal reference list (M03, an API request). instaplay check --offline uses no network at all — then publish checks the category and tags (CLI: commands).