webStorageAdapter
function webStorageAdapter( storage, key, options?): PersistAdapter;Persist to any Storage-shaped thing.
storage may be a thunk, and that is the form the built-in adapters use:
merely reading globalThis.localStorage throws SecurityError when storage
is blocked (a sandboxed iframe, third-party cookies off), so evaluating it at
module scope would blow up on import — before any try/catch here could help.
Behind a thunk, every access happens inside one.
Blocked storage, corrupt JSON, a foreign schema, or a full quota all degrade
to a silent no-op — persistence is best-effort; it must never break the
store. Pass onError to observe the failures anyway.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
storage | | StorageLike | (() => | StorageLike | undefined) |
key | string |
options? | WebStorageAdapterOptions |