Replies: 2 comments 3 replies
-
you can not |
Beta Was this translation helpful? Give feedback.
-
Hi , I've also followed the above docs to setup ssr in nextjs app router
Currently every time a user clicks a link to this page it will trigger a prefetch and request from the server. If a new queryClient is returned for each request how would it know if the data is stale? Is there any way to force Nextjs not to call the server when a link is clicked so that the client queryClient will handle data fetching? |
Beta Was this translation helpful? Give feedback.
-
Expected:
Previously in Pages Router, it was achieved using
getInitialProps
, like so:In App Router, based on the docs, this is the only way to query data on the server:
https://tanstack.com/query/latest/docs/framework/react/guides/advanced-ssr
With this setup it will hit the server and wait for data fetching all the time, which is a slow navigation experience. How to detect whether it's the first load? Or return cached data instantly?
Beta Was this translation helpful? Give feedback.
All reactions