Skip to main content

Dev mock

The mock lets you build and test your game in a plain browser — with no Gamma Games app — by simulating the bridge locally. It is off by default and never touches real balances: state is in-memory, mirrored to localStorage so it survives a reload.

Enable it

Call configure({mock: ...}) before gamma.ready():

import {gamma} from '@swiftware/gamma-sdk';

gamma.configure({
readyTimeoutMs: 1500, // how long to wait for a real host first
storageKey: 'mygame_save', // localStorage key for the progress fallback
mock: true, // ← enable; or pass an object to seed values
});

await gamma.ready();
console.log(gamma.isInApp); // always false with the mock; true only in-app

Seed specific values with the object form:

gamma.configure({
mock: {
coins: 500,
coinValue: {usdPerCoin: 0.02},
player: {displayName: 'Dev Player'},
},
});

With the mock enabled, getCoins, spendCoins, earnCoins, saveProgress, loadProgress, getPlayer, and getCoinValue all work against the local simulation — including the same validation the real bridge enforces (amount/reason limits, insufficient balance, etc.).

⚠️ Don't ship it enabled

In production, leave the mock off so the integration stays inert outside the Gamma Games app (see App-only & offline). A good pattern:

gamma.configure({mock: import.meta.env.DEV}); // only in local dev

Interactive test harness

A ready-made harness that exercises every method is included with the package and mirrored here: open the test harness. It shows an "in-app" vs "dev mock" badge and logs every SDK response.

Ask:View .md