Is it best practice to use different QueryClients per user?
Assuming the anonymous user as a distinct user, is it wise to create a new
QueryClient when the user switches from logged in to logged out or vice versa?2 Replies
flat-fuchsia•4y ago
Not directly an answer… To isolate cached data per user on the same browser, we decided to make the userID a part of all our query keys. Thanks to queryKey factories we don’t have to think about adding it anymore.
Regarding your question, I think it all depends on your query client configuration. If you have a lot of defaults in your queryClient for ex. It might be painful to re create it
gradual-turquoise•4y ago
you can also just clear the cache with
queryClient.clear() when the user logs out. no need to really re-create it