Function that returns the current state to be saved after each command.
OptionalserializeSerializer. Default: JSON.stringify
OptionaldeserializeDeserializer. Return null/undefined to skip rehydration. Default: JSON.parse
OptionalvalidateValidate deserialized state before returning from load(). Return true to accept, false to reject (load() returns null). Use this to reject stale or structurally invalid persisted state after deploys that change the shape of persisted data.
OptionalfilterWhich actions trigger a save. Default: all successful dispatches.
OptionalstorageStorage backend. Default: globalThis.localStorage
Pass sessionStorage for session-scoped persistence.
OptionalcoalesceWhen true, collapse back-to-back saves within the same microtask into one.
Trades 1 microtask of latency for one getState() + JSON.stringify() +
setItem() cycle per burst, regardless of how many dispatches triggered it.
Use when the same state is touched by many rapid commands (form input, scroll tracking, batched cart updates). Default: false (every successful dispatch saves immediately, matching pre-v1.2 behavior).
Storage key. Use a unique prefix per feature to avoid collisions.