Cloud saves
Per-slot saves with last-write-wins or conflict-safe writes, plus a durable offline queue.
A save is a JSON blob under a slot name you choose (e.g. slot1, settings). Saves are per-player and versioned.
await tg.saves.put('slot1', { level: 4, coins: 120 });
const { data } = await tg.saves.get('slot1'); Conflict-safe writes (OCC)
By default a write is last-write-wins. To avoid clobbering a concurrent write (two tabs, a flaky network retry), pass the version you read as ifMatch — a stale version returns save_conflict. Re-read, merge, and retry.
const { data, version } = await tg.saves.get('slot1');
await tg.saves.put('slot1', next, { ifMatch: version }); // throws save_conflict if stale Offline resilience
tg.saves.queue(slot, data) writes to a durable outbox in localStorage: it survives a dropped connection and replays on reconnect, coalescing to last-write-wins per slot and carrying an idempotency key. You never handle the retry logic.