Skip to main content
End-to-end examples for the patterns most apps need. They use Vue (path hooks); React is the same shape with plain values instead of refs.

Multiple APIs

One instance per API, shared config via createKweriClients, one set of hooks per API. DevTools share a single switchable panel.

Mutation with error handling

Because the default fetcher throws on non-2xx, a failed write lands in catch with err.status and err.detail.

Error handling without try/catch

Queries surface errors reactively, and mutate() (fire-and-forget) sets isError/error without throwing — so most UIs need no try/catch.
For success/error callbacks without any reactive state, use the low-level kweri.mutate(endpoint, params, { onSuccess, onError }).

List with loading / error / empty states

Optimistic update

Snapshot the cache, apply the change immediately, roll back on failure. (Path hooks don’t take lifecycle callbacks, so do it inline.)

Dependent queries

Wait for one query before firing another with enabled. Pass the params as a computed so the dependent query re-runs when the first resolves — a plain object would capture undefined once and never update.
A computed/ref for params makes the query reactive (it re-fetches when the value changes — the basis for search and pagination too). The as any is currently needed because path-hook param types don’t yet include refs.

Per-resource freshness

Different data ages differently — override staleTime/cacheTime per call instead of one global.

Search & pagination (reactive params)

A computed params object re-fetches whenever it changes. Previously-seen pages stay cached, so paging back is instant.
kweri deduplicates in-flight requests, but doesn’t debounce keystrokes — for fast typing, debounce q before binding it.