react-query-questions
solid-query-questions
table-questions
virtual-questions
router-questions
react-charts-questions
ranger-questions
vue-query-questions
svelte-query-questions
bling-questions
form-questions
angular-query-questions
start-questions
db-questions
start-showcase
router-showcase
📣-announcements
How do I tell useQuery that initial data is prefetched on the server?
MyData | undefined
because useQuery doesn't know the initial data will be there. How do I solve that? For now I solved it by setting initialData: {} as MyData
in useQuery but I wonder if there is a better way?How to use CSS Modules with TanStack Start?
response.json() failing only within useQuery - receiving HTML instead of JSON
"next": "14.2.5"
What's strange is:
The endpoint works perfectly when called directly or in a normal fetch...refresh in useQueries cause infinite rerender
useAllData
causes a re-render, whereas useOneData
data works normally?
```
const useOneData = () => {
const { data, refetch } = useQuery(["a_key"], async () => {...`getPreviousPageParam` final parameter - is it the "current" page or is it the previous page?
useInfiniteQuery
.
So the documentation code here:...
Setting gcTime on prefetched data
prefetchQuery
on the serverside to fetch some data for the page. The page that is loaded does not actively have a useSuspenseQuery
call for that particular piece of data, it is only used on other pages. The useSuspenseQuery
sets a gcTime of Infinity to disable garbage collection on the prefetched data. The prefetch call also sets gcTime
of Infinity.
The problem:
The prefetched data stored in the query cache gets a gcTime of "5 minutes" when there are no active queries subscribed to it, since there is nobody there to tell it otherwise. That means there doesn't seem to be a way to keep the prefetched data around until it's actually used by a query hook, without just calling a "dummy" hook on every page to make sure gcTime is set?...Is it possible to globally configure QueryClient *after* it's instantiated?
Simple question regarding redirecting on error
`fetchNextPage` - how does it work?
fetchNextPage
unpack the result of the queryFn
with the new page parameters and the pop it into the pages
array? Or does it replace the data.pages
entirely? I doubt it's the latter, right? But what it's doing underneath seems really weird and I don't understand it.Issue with re-validation on production with Next.js App router.
ensureQueryData and preloading routes
NextJS 15: HydrationBoundary not passing data to client component when prefetching
data always returns the last api response
Great Chance
I have problem with reconnection

Optimistic Updates with Multiple Cache Keys in TanStack Query
How to handle query key requiring object with bigint?
Using useInfiniteQuery to gather all pages
useInfiniteQuery
. However, we also have a case where we need to fetch all pages of data "in bulk". That is, if there are 5 pages in total I need to be able to get all 5 before returning data to the application.
Each request requires a "token" parameter that comes from the previous page's response. I understand how to get that via getNextPageParam
, and I know that the hook's return object includes a function called fetchNextPage
. But the examples I've seen in the docs all assume that the app only wants one page at a time and only gets the next page based on an event from the user (button click, etc.).
Is this possible, with this particular hook? I wrote a custom hook that uses queryClient.fetchQuery(...)
in a loop. It works, but it doesn't update either after the data becomes stale or after the cache is forcibly cleared with invalidateQueries()
....Wait for multiple queries to succeed
Inactive queries cause refetching
