Skip to main content

Constructor

KweriOptions

Example


Querying

kweri.query

Execute a query. Returns cached data immediately if fresh; otherwise fetches and caches the result.
Concurrent calls for the same key share a single in-flight request.

Mutations

kweri.mutate

Execute a mutation with full lifecycle hooks.
See Mutations for the full options reference.

Cache access

kweri.getCachedData

Return the currently cached data for a query without triggering a fetch.

kweri.setCachedData

Write data directly into the cache. The entry is marked as success with updatedAt = now.
Useful for optimistic updates before a mutation fires.

Invalidation

kweri.invalidateQuery

Mark a specific cached entry as stale. Subscribers will receive a background refetch on their next render.

kweri.invalidateByPath

Mark all entries whose cache key contains the given string or matches the given regex as stale.

kweri.invalidateQueryByKey

Invalidate by the raw serialized cache key — primarily used by DevTools.

Removal

kweri.removeQuery

Delete a cache entry entirely.

kweri.removeQueryByKey

Delete by raw key string.

Subscriptions

kweri.subscribe

Subscribe to cache changes for a specific query. Returns an unsubscribe function.

kweri.onCacheChange

Subscribe to all cache changes globally. Useful for logging or custom devtools.

Status

kweri.isInFlight

Check whether a fetch is currently in progress for a given query.

kweri.getQueryKey

Get the serialized cache key for a query/params pair.

Garbage collection

kweri.startGC / kweri.stopGC

Manually control the eviction engine. If gcInterval is set in KweriOptions, GC starts automatically on construction.

Devtools

kweri.getDevToolsSnapshot

Returns a point-in-time snapshot of the cache, observer counts, and in-flight requests. Used internally by the DevTools panel.

Lifecycle

kweri.destroy

Stops the GC timer, unmounts DevTools, and clears all subscriptions. Call this when the application shuts down or when testing.

Public properties