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 underkey, orfallbackwhen 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— Deletekeyfrom 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 underkey, orfallback.write(key: string, value: unknown): void— StoreJSON.stringify(value).


