React · Senior · Question 36 of 75

How do you correctly pass TanStack Query data loaded on the server to client components?

Explanation

The server creates a QueryClient per request, runs prefetchQuery and serializes the cache via dehydrate(queryClient). The client-side HydrationBoundary puts this data into the client cache, and useQuery with the same key gets it immediately without refetching.

Further reading

Problem with a question

React · Senior · question 36

Test yourself

Take the React · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz