Is it possible to access browser QueryClient without passing it as a function parameter?
I couldn't seem to find a quick answer, but I have a
I know I could put this function in my
Thanks a lot!
beforeLoad that I'd like to call to verify permissions and since I'm use Tanstack Query I want to use ensureQueryData so I can utilize browser cache if it exists. I would like to extract the logic in to a function and I was curious if I could access my client without needing to pass it as a function parameter?I know I could put this function in my
context but I guess I'm just asking conceptually how to access the browser QueryClient outside react land? In nextjs, tanstack query has a getQueryClient you could export https://tanstack.com/query/latest/docs/framework/react/guides/advanced-ssr#initial-setup to ensure you were grabbing the same query client on the browser but a new instance on each server request. Is it okay to do something similar like the below so i can just import getQueryClient in my client side functions?Thanks a lot!
Welcome to the Advanced Server Rendering guide, where you will learn all about using React Query with streaming, Server Components and the Next.js app router. You might want to read the before this on...
