Quickstart
Integrate the SDK in three steps.
import {gamma} from '@swiftware/gamma-sdk';
// 1. Wait until the SDK has settled (real host in-app, or fallback outside it).
await gamma.ready();
// 2. Load the player's save (account-bound in-app, localStorage outside).
await gamma.storage.init();
const state = (await gamma.storage.load()) ?? {schemaVersion: 1};
// 3. Use coins / save progress. Only grant a reward when `ok` is true.
const res = await gamma.spendCoins(50, 'extra_life');
if (res.ok) {
grantExtraLife();
}
await gamma.storage.save(state);
That's the whole happy path. The rest of the docs are detail.
A more complete boot sequence
import {gamma} from '@swiftware/gamma-sdk';
async function boot() {
await gamma.ready();
if (gamma.isInApp) {
const player = await gamma.getPlayer();
if (player) greet(player.displayName);
}
await gamma.storage.init();
const save = (await gamma.storage.load()) ?? defaultState();
applyState(save);
startGame();
}
boot();
Things to remember
- Coins only work inside the Gamma Games app. Outside it, coin calls return
{ok: false, error: 'no_transport'}. Gate features ongamma.isInApp. See App-only & offline. - Never grant a reward before
spendCoinsresolves withok: true. - Include a
schemaVersionin every saved object so you can migrate later. - Test outside the app with the opt-in dev mock.
Prefer to let an AI do it? See Integrate with AI.
Ask:View .md