Relative Content

Tag Archive for next.jscachingreact-querytanstackreact-querygetserversideprops

getServerSideProps with ReactQuery doesn’t cache properly

im using nextjs 14.2.3 (page router) with react query, and my data is not cached when im trying to call an api on the server with getServerSideProps with reactQuery.
when ever i change my route, the same request with the same queryKey is fetching again and again.
i got it from ReactQueryDevtools, the ‘last update’ in ReactQueryDevtools updates per navigating between my routes. Also i used gcTime and staleTime of 5 minutes,all my api queries are fresh but it send request again adn again, and i didnt use any refetch in my project to cause this behaviour. i want to cache my data when the first getServerSide props called, i dont want to send any requests when my queries are fresh.