Clearing up comment for making query client
I cant really understand what the comment means in the else statement regarding suspense - can anyone clear this up? Thanks!

4 Replies
generous-apricot•15mo ago
QueryClientProvider uses context under the hood. It's solely FE feature, context doesn't exist on the server, so when your react query runs on the server you create a new query client, append data to it and send it back to the FE. This have some limitations as with the new client you lose everything that was stored in the cache. So you start from scratch having only the data you append to the QueryClient on the server
My explanation is pretty basic and inaccurate
generous-apricot•15mo ago
Server Rendering & Hydration | TanStack Query React Docs
In this guide you'll learn how to use React Query with server rendering.
See the guide on Prefetching & Router Integration for some background. You might also want to check out the Performance & Request Waterfalls guide before that.
generous-apricot•15mo ago
Read this to understand what's happening
grumpy-cyanOP•15mo ago
So we do some stuff on the server with a freshly created client - then we dehydrate it, send it to the client, and the single (reused) query client will take that and populate the cache and other stuff accordingly to be in sync.
Ok thank you!!
Appreciate the response