Phaser AE

Saved data

Free packv3.0.0-3Logic

A small key-value store on `game.save` for what a game must remember between sessions: a high score, a settings screen, unlocked levels, a checkpoint. It writes to localStorage when it can and to memory when it cannot, and it never throws because the browser would not keep a score.

This is a Free pack. Every phaser.io account can use it in their games.

Released October 14, 2026 · updated October 20, 2026

Saved data: a screenshot of its demo
A note about these graphics

Expansion packs don't come with graphics. This screenshot is one way of drawing what the pack does, made for its demo: none of the sprites, tiles or backgrounds in it are in the pack.

That's by design. A pack is a game's logic, mechanics and effects, and it works with whatever art you give it. Some packs draw effects, backdrops or 3D scenes of their own, but none carries a game's sprites.

So the look is yours. Make the art on phaser.io, bring your own, or let your agent draw it in code: the same pack can look like anything.

The pack

save

function save(opts: SaveOptions = {}): Pack<{ save: SaveApi }>

The save pack: game.save, JSON under opts.namespace in localStorage or, failing that, memory. No columns, steps or hooks.

Types

SaveApi

interface SaveApi

What game.save presents. Storage failures degrade to memory; invalid JSON writes throw before changing data.

  • read<T>(key: string, fallback: T): T — The parsed value under key, or fallback when absent or not valid JSON.
  • write(key: string, value: unknown): void — Store a JSON-serializable value. Throws TypeError for cycles, BigInt or an undefined serialization. Storage failure switches this session to memory.
  • remove(key: string): void — Delete key from both stores.
  • keys(): string[] — Every key in this namespace.
  • clear(): void — Remove every key in this namespace; other namespaces are untouched.
  • readonly persistent: boolean — True while this session uses localStorage; false after any storage failure (latest changes will be lost on reload).

SaveOptions

interface SaveOptions

Manifest options for the save pack.

  • namespace?: string — Key prefix; default 'phaser-ae'. Give each game its own, or two games on one origin share a store.

SaveTap

interface SaveTap

What the pack puts in the registry under ('save', 'save'), so another PACK can persist a value without importing this one — and work fine when it is not composed.

  • name: string — The registry name: 'save'.
  • read<T>(key: string, fallback: T): T — The parsed value under key, or fallback.
  • write(key: string, value: unknown): void — Store JSON.stringify(value).