How i can use QueryClient in server and client component?
I need to prefetch data within a server component and get this data from the cache in a client component, how would I use the same QueryClient in both?
Could I export a single
QueryClient
from a separate file and import it in my components?4 Replies
foreign-sapphire•2y ago
Dehydrate and hydrate. Read the docs
quickest-silverOP•2y ago
can you give an example? or send the link to the docs that explains it, pls
I didn't find specifically what I needed
foreign-sapphire•2y ago
Server Rendering & Hydration | TanStack Query 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.
quickest-silverOP•2y ago
hmm, they are using the old version of next, that was confusing me, it would be interesting if they updated the examples in the future for the next 13/14
but I already managed to "convert" with the help of AI
thanks 🤙