Constructor
KweriOptions
Example
Querying
kweri.query
Execute a query. Returns cached data immediately if fresh; otherwise fetches and caches the result.
Mutations
kweri.mutate
Execute a mutation with full lifecycle hooks.
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.
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.