Snapshot Persistence

Serialization

A snapshot is a plain object: { value, context, event }. serializeSnapshot() makes it JSON-safe so you can store it anywhere โ€” localStorage, a database, or send it over the wire. deserializeSnapshot() validates the shape and reconstructs it. Increment the counter, save, reset to zero, then load to resume exactly where you left off.

interactive demo
0
count
๐Ÿ–ฅ SSR hydration โ€” serialize server-side, resume client-side
๐Ÿ’พ Offline resume โ€” persist progress across sessions
โ†ฉ Undo / redo โ€” snapshot history as an array
๐ŸชŸ Tab / window state sync via BroadcastChannel