Saving Progress
The autosave blob, what belongs in it, and where local-only data should live instead.
Every game gets one autosave document per player. It comes back on the next boot, on any device, and needs no declaration.
Autosave
// Persist. Call it when something worth keeping changes, not every frame.
sdk.singlePlayer.actions.saveGameState({ gameState: { unlockedShips, bestCombo } })
// Read it back on the next boot.
const info = await sdk.ready()
const saved = info.initialGameState?.gameState ?? {}
// or, after ready(): sdk.gameState
The shape is yours, up to 1 MiB of JSON. Version it: put a v field in the object and migrate old shapes on read, because a player's save can be older than your latest upload.
What Belongs in It
Progress a player would be upset to lose: unlocks, settings, a campaign position, lifetime counters such as total kills. Not run state, and not anything the platform already owns:
- Level unlocks and best stars are stored by the host from your
levelAttemptreports. - Best scores ride
gameOver. - A best worth ranking belongs on a leaderboard, and a milestone worth showing off is an achievement your game unlocks.
More than One Document
Games that need several save files per player, or a run in progress beside a settings profile, use named cloud save slots. Autosave stays the default; slots are the upgrade.
Local-Only Data
Replays, ghosts and large binary records do not belong in the autosave. Use localStorage for small values and IndexedDB for large ones. Browser storage stays on one device and surface, is not always separate per account, and is not cloud-synced; treat it as a cache and handle it being empty.
Guests
Signed-out players have no saved state: initialGameState is null and saves are dropped. Read "nothing saved" and "guest" the same way.