Cache and storage
The SDK uses an internal in-memory LRU cache with TTL eviction. Cache configuration is passed at initialization: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 theStorage interface:
localStorage satisfies this interface directly:
Custom fetch
The SDK uses the globalfetch by default. You can provide a custom fetch implementation for SSR, testing, or environments where fetch is not available:
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
fetchandstorage - 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