# Quickstart

Integrate the SDK in three steps.

```js
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

```js
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 on `gamma.isInApp`. See
  [App-only & offline](../guides/app-only-and-offline.md).
- **Never grant a reward before** `spendCoins` resolves with `ok: true`.
- **Include a `schemaVersion`** in every saved object so you can migrate later.
- **Test outside the app** with the opt-in [dev mock](../guides/dev-mock.md).

Prefer to let an AI do it? See [Integrate with AI](../ai-integration.mdx).
