The app hammers the API on every tab switch
Default staleTime of zero combined with refetchOnWindowFocus means every return to the tab fires every active query, which is fine in dev and ruinous on a real backend.
Refetches tuned to real freshness
Using TanStack Query?
TanStack Query starts as a few hooks and quietly becomes the data layer of the entire app. When invalidation goes wrong, stale time is left at the default, or server components hand hydration a snapshot the client does not agree with, the symptoms are rarely where the bug lives. We trace it through the devtools, the query keys and the server boundary until the network panel matches what the user actually needs.
What it is
TanStack Query, long known as React Query, is a client-side data-fetching and caching library for React, Vue, Svelte, Solid and Angular. It handles caching, background refetching, deduplication, pagination, mutations and devtools without forcing a particular transport underneath, which means it works happily over REST, GraphQL or a plain fetch call.
It has become the default answer for anything more complex than a single useEffect fetch. The core idea is that server state is not the same as client state: it goes stale, needs to be revalidated, and should be shared between components without a store. By 2026 it is paired with server components, streaming SSR and framework-level caches in ways the original React Query authors never imagined.
The honest version
No technology is all upside. This is where TanStack Query earns its place and where it tends to cause trouble.
Sound familiar?
The TanStack Query problems that bring people to us, and what you have once each one is fixed.
Default staleTime of zero combined with refetchOnWindowFocus means every return to the tab fires every active query, which is fine in dev and ruinous on a real backend.
Refetches tuned to real freshness
A server render that fetched with one QueryClient and a client that boots with another, no dehydrated state in between, so the first client render disagrees with the HTML and React throws it away.
SSR cache handed through cleanly
A mutation that invalidated the wrong key, or a key that changed identity between renders, so the query it was supposed to refresh never saw the invalidation and kept serving stale data.
Invalidation matches the real keys
A queryFn that returned undefined on a 404 instead of throwing, which TanStack Query treats as a logic error rather than a missing resource. The component downstream sees a broken cache entry.
Missing and error cases handled explicitly
A test harness, a Storybook story or a server component that rendered without QueryClientProvider in the tree. Easy to miss until exactly one route breaks.
Provider wired in every entry point
A getNextPageParam that reads a field from the wrong place in the response, or an API that signals end of list differently than the hook expected.
Pagination carries to the final page
Five components each call the same useQuery with the same key but mount at slightly different times with a stale time of zero, and the dedupe window is too short to collapse them.
Shared data cached once
An onError handler that restores the wrong snapshot, or a mutation that races with a refetch and ends up persisting the stale version instead of the optimistic one.
Optimistic path safe under retries
What we do
Call us for one runaway query, or hand us the whole data layer.
How it works
Tell us what's going wrong. We look at it, then tell you plainly what's wrong and what it will cost.
We fix the cause, not the symptom. If something is down, getting it back up comes first.
Backups, monitoring, updates and access, so the same problem can't quietly come back.
You get a plain-language write-up. Or we stay on for hosting, upkeep and new work.
Often found together
We work on the whole stack, so the problem can be wherever it actually is.
The defaults are optimistic: staleTime is zero, refetchOnWindowFocus is on, and refetchOnMount is on. Most apps want a staleTime measured in seconds or minutes for data that does not change on every keystroke, and refetchOnWindowFocus turned off for things that do not need per-tab freshness. We tune per query rather than globally.
Use a single QueryClient per request on the server, prefetch the queries that render in the HTML, dehydrate that state and pass it into HydrationBoundary on the client. The mismatch disappears once both halves agree on the initial snapshot.
They serve different jobs. Server actions are great for writes that redirect or revalidate a route; TanStack Query shines when the client needs its own cache, optimistic updates, infinite scroll or background refetching. Most apps end up using both and letting each do what it is best at.
Use a key factory that produces arrays like users.detail(id) and users.list(filters), import it everywhere, and never build keys by hand in a component. It makes invalidation predictable and gives TypeScript something to help with.
The mutation returned a 200 but the invalidateQueries call used a key that does not match the one the list is subscribed to. The fix is usually either moving to the same key factory or widening the invalidation to a prefix, depending on how cheap the refetch is.
The first conversation is free. Describe the hooks that are misbehaving, the framework around them, and we send back a price before any work gets scheduled.
Free estimate
Tell us what you're running and what's going wrong. A person reads it and comes back with an estimate.
Your message is with a real person, and we'll get back to you soon.
Rather talk now? Call us: