You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when using next.js SSR with react-query a global queryClient is created. This client get hydrated during server side rendering with the data provided from getInitialProps or getServerSideProps. If we have a secured endpoint (e.g. account information) that is indistinguishable between users from a query key perspective (users are separated by a session cookie) and two users now simultaneously access the account page. The SSR fetches the correct data and then hydrates the global query client. Could it be that then the client has only one of the account data in the cache and the SSR renders the same data for both users?
Would setting the cacheTime to 0 make a difference? (Once #1442 got released)
Or is this a bad practice and we should add a unique user identifier to the query key?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
when using next.js SSR with react-query a global
queryClient
is created. This client get hydrated during server side rendering with the data provided fromgetInitialProps
orgetServerSideProps
. If we have a secured endpoint (e.g. account information) that is indistinguishable between users from a query key perspective (users are separated by a session cookie) and two users now simultaneously access the account page. The SSR fetches the correct data and then hydrates the global query client. Could it be that then the client has only one of the account data in the cache and the SSR renders the same data for both users?Would setting the
cacheTime
to0
make a difference? (Once #1442 got released)Or is this a bad practice and we should add a unique user identifier to the query key?
According to the docs it's ok to use a global client: https://react-query.tanstack.com/guides/ssr#using-hydration
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions