Skip to content

Multiple query client providers, or limit storage / broadcast pr queryKey #6321

Answered by TkDodo
tbowmo asked this question in Q&A
Discussion options

You must be logged in to vote

So can we either limit storage / broadcasts to a specific set of queryKeys

Yes, storage has options for that. Not sure about broadcast

or can we have two queryclient providers for our app?

you can, but then you'd need to pass the queryClient specifically to each invocation of useQuery, or make your own abstraction:

const useAuthQuery = (opts) => {
  return useQuery(opts, authQueryClient)
}
const useNormalQuery = (opts) => {
  return useQuery(opts, normalQueryClient)
}

you can't use useQueryClient because that would just look up the nearest provider

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by tbowmo
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants