StorageBackend such as localStorage.
Request deduplication
When multiple controllers request the same data, the SDK deduplicates in-flight requests and reuses cached results:Cache configuration
Control cache behavior with thecache option at SDK initialization:
In the browser,
localStorage is used automatically when a StorageBackend is available. Pass storage: localStorage or a custom object.
Storage backends
A storage backend is any object matching a subset of theStorage interface:
Browser (localStorage)
Node.js (memory store)
For SSR or build scripts, pass an in-memory store:sessionStorage
SwaplocalStorage for sessionStorage to keep cached data only while the tab is open:
Cache invalidation
The SDK does not expose a public cache invalidation API. To clear cached data, reset the SDK singleton or dispose individual controllers:Search cache
Thesearch controller uses the prepare endpoint to cache expensive work. get() automatically prepares the query when needed and retries a 425 response until results are ready.
searchId, the server maintains the prepared state for a short window:
Custom fetch
The SDK uses the globalfetch by default. Provide a custom implementation via the fetch option for SSR runtimes, testing, or environments where fetch is unavailable or blocked:
xhrFetch (browser fallback)
xhrFetch is an XMLHttpRequest-based fetch shipped with the SDK. Use it when ad blockers, browser extensions, or restrictive network policies intercept fetch calls:
Custom fetch
Any function matching theFetchFn signature can be passed. Common uses:
- SSR / Node: inject a Node-compatible fetch on older runtimes.
- Testing: stub responses without intercepting global
fetch. - Instrumentation: add tracing or auth headers around the request.
fetch returns. Your adapter only needs to issue the request and return a Response.
Next steps
Performance
Learn performance optimization techniques.
Best practices
Review SDK best practices and common pitfalls.