Skip to main content

Cache and storage

The SDK uses an internal in-memory LRU cache with TTL eviction. Cache configuration is passed at initialization:
The public cache object exposed in v2 has been removed. Cache behavior is controlled through cache and storage in SdkConfig.

Cache configuration

The SDK persists cache values to the configured storage backend when available. In the browser, localStorage is used automatically. Pass a custom StorageBackend if you need a different store shape, prefix, or runtime (for example, Node.js, sessionStorage, or an HTTP service).

StorageBackend

A storage backend is any object matching this subset of the Storage interface:
In the browser, localStorage satisfies this interface directly:
For Node.js or SSR, pass an object that wraps your store:

Custom fetch

The SDK uses the global fetch by default. You can provide a custom fetch implementation for SSR, testing, or environments where fetch is not available:
The SDK also exports xhrFetch, an XMLHttpRequest-based fetch alternative for environments where fetch is blocked by ad blockers or browser extensions:

Singleton access

After initialization, access the SDK anywhere:

Technical details

  • Runtime: Browser (ESM) and Node.js with a custom fetch and storage
  • TypeScript: Full type definitions included
  • Dependencies: None
  • Bundle: Tree-shakeable ES modules
  • Caching: In-memory LRU cache with TTL and optional storage persistence
  • Request deduplication: In-flight requests are deduplicated automatically

Next steps