Replies: 2 comments 5 replies
|
The model you want is the experimental streamed hydration path, not the route-level Wrap the app in <QueryClientProvider client={queryClient}>
<ReactQueryStreamedHydration>{children}</ReactQueryStreamedHydration>
</QueryClientProvider>The important boundary is the query function: because it lives in a client component module, don't import DB/server-only code there. If the query needs a server-only procedure, expose that through a route handler/server function/RPC endpoint, or keep a small Server Component prefetch wrapper at the subtree boundary. |
I’m not really sure that this is the case. The way I see it, calling The suspension happens where If that’s not the case, please show a reproduction.
I am the first one to state / admit that React Query was not specifically made to work with nextJs. It’s a client-side async state manager that predates the app router by years. If you fully embrace the nextJs model, including cache components, why would you need React Query? |

I would not use the
StreamedHydrationpackage. It builds on a nextJs specific API and we haven’t really worked in that direction lately. It’s also quite magic. Moving prefetching down is an idea, TanStack Start is an idea, or not using Query is also an idea.