BrowserKeyValueStore.ts
BrowserKeyValueStore.ts overview
Section titled “BrowserKeyValueStore.ts overview”Browser-backed KeyValueStore layers for client-side Effect programs.
This module provides browser implementations of the unstable persistence
KeyValueStore service. Use layerLocalStorage for small
origin-scoped values that should survive reloads and browser restarts, use
layerSessionStorage for tab / page-session state, and use
layerIndexedDb when the store should be asynchronous and backed by
IndexedDB. The IndexedDB layer requires the browser IndexedDb service and
accepts an optional database name.
Since v4.0.0
Exports Grouped by Category
Section titled “Exports Grouped by Category”layers
Section titled “layers”layerIndexedDb
Section titled “layerIndexedDb”Creates a KeyValueStore layer backed by IndexedDB.
When to use
Use when you need persistent asynchronous IndexedDB storage for a browser
KeyValueStore instead of the synchronous Web Storage APIs.
Details
The database name defaults to "effect_key_value_store". The layer requires
the IndexedDb service and stores string and Uint8Array values in the same
backing object store.
Gotchas
IndexedDB may be unavailable or blocked by browser settings, private browsing,
quota limits, or restricted contexts. The string and Uint8Array accessors do
not coerce values stored with the other representation.
See
layerLocalStoragefor synchronous persistent Web StoragelayerSessionStoragefor synchronous tab-session Web Storage
Signature
declare const layerIndexedDb: (options?: { readonly database?: string | undefined}) => Layer.Layer<KeyValueStore.KeyValueStore, never, IndexedDb>Since v4.0.0
layerLocalStorage
Section titled “layerLocalStorage”Creates a KeyValueStore layer that uses the browser’s localStorage API and stores values between browser sessions.
Signature
declare const layerLocalStorage: Layer.Layer<KeyValueStore.KeyValueStore, never, never>Since v4.0.0
layerSessionStorage
Section titled “layerSessionStorage”Creates a KeyValueStore layer that uses the browser’s sessionStorage API and stores values only for the current session.
Signature
declare const layerSessionStorage: Layer.Layer<KeyValueStore.KeyValueStore, never, never>Since v4.0.0