Skip to Content
API Reference@parity/product-sdk-local-storageOverview

@parity/product-sdk-local-storage

One key-value API across the host container and the browser.

createLocalKvStore returns a LocalKvStore that uses the host-provided HostLocalStorage when running inside a Polkadot host container and falls back to browser localStorage otherwise, so app code reads and writes the same way on desktop, mobile, and web.

npm install @parity/product-sdk-local-storage

Exports

Functions

NameSummary
createLocalKvStore()Create a key-value store.

Interfaces

NameSummary
LocalKvStoreAsync string local key-value store, with getJSON/setJSON for structured values. Returned by createLocalKvStore.
LocalKvStoreOptionsOptional configuration for createLocalKvStore: a key prefix to namespace entries, or an explicit host-storage handle that overrides auto-detection.

Re-exports

Convenience re-exports from leaf packages. Click through for the canonical documentation.

NameKindSource package
HostLocalStoragetype@parity/product-sdk-host

Functions

createLocalKvStore()

Create a key-value store.

Uses the host localStorage when inside a container. The SDK is designed to run exclusively inside a host container.

createLocalKvStore(options?: LocalKvStoreOptions): Promise<LocalKvStore>

Throws

  • If host storage is unavailable (not inside a container).

Interfaces

interface LocalKvStore

Async string local key-value store, with getJSON/setJSON for structured values. Returned by createLocalKvStore.

Methods

get
get(key: string): Promise<string | null>
getJSON
getJSON(key: string): Promise<T | null>
remove
remove(key: string): Promise<void>
set
set(key: string, value: string): Promise<void>
setJSON
setJSON(key: string, value: unknown): Promise<void>

interface LocalKvStoreOptions

Optional configuration for createLocalKvStore: a key prefix to namespace entries, or an explicit host-storage handle that overrides auto-detection.

Properties

hostLocalStorage
propertyoptional{ clear: unknown; readBytes: unknown; readJSON: unknown; readString: unknown; writeBytes: unknown; writeJSON: unknown; writeString: unknown }

Override auto-detection. When provided, routes all ops through this host storage.

prefix
propertyoptionalstring

Key prefix to namespace storage keys (e.g. “myapp” → keys become “myapp:theme”).

Last updated on