@statesync/persistence / LocalStorageBackendOptions
Interface: LocalStorageBackendOptions
Defined in: persistence/src/storage/local-storage.ts:10
Configuration options for the localStorage storage backend.
Allows customization of the storage key and serialization behavior used when persisting snapshot data to the browser's localStorage API.
Properties
deserialize()?
optional deserialize: (data) => SnapshotEnvelope<unknown>;Defined in: persistence/src/storage/local-storage.ts:37
Custom deserialization function for converting a stored string back into a snapshot envelope.
Parameters
| Parameter | Type | Description |
|---|---|---|
data | string | The raw string retrieved from localStorage. |
Returns
SnapshotEnvelope<unknown>
The deserialized snapshot envelope.
Default
JSON.parsekey
key: string;Defined in: persistence/src/storage/local-storage.ts:17
The key under which snapshot data is stored in localStorage.
Must be unique per application or state instance to avoid collisions with other data stored in the same origin's localStorage.
serialize()?
optional serialize: (snapshot) => string;Defined in: persistence/src/storage/local-storage.ts:27
Custom serialization function for converting a snapshot envelope into a string suitable for localStorage storage.
Parameters
| Parameter | Type | Description |
|---|---|---|
snapshot | SnapshotEnvelope<unknown> | The snapshot envelope to serialize. |
Returns
string
A string representation of the snapshot.
Default
JSON.stringify