Do server components cache their results with React Query?

I have a project that uses RSC to break down a single client component that fetches data into many server components and the minimal required client components. I am pretty sure Server Components don't cache their results, so is there a way I can update a server component to re-fetch the data? I'd rather not do some hacky thing like upping a counter to force a refresh. Can't say I didn't think about it though lol.
1 Reply
Stward
Stward9mo ago
useQuery can only be used in a client component, anyway. So you'll get caching and all the goodies from TanStack Query. If you're prefetching on the server, I'm not entirely sure, but my guess is that you could invalidate the query on the client, if needed. Might be helpful to read more about this: https://tanstack.com/query/latest/docs/framework/react/guides/advanced-ssr.
Overview | TanStack Query Docs
TanStack Query (FKA React Query) is often described as the missing data-fetching library for web applications, but in more technical terms, it makes fetching, caching, synchronizing and updating server state in your web applications a breeze. Motivation
Want results from more Discord servers?
Add your server