Replies: 1 comment
-
|
i think ists because server query client create fresh on every request so ur prefectquery always run new If you don’t need SSR on return visits, remove prefetchQuery and let the client useQuery read from its cache (or refetch). You’ll lose SSR HTML for that route, but avoid the server wait. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, while testing data fetching using
prefetchQueryandHydrationBoundaryin a Next.js environment, I encountered a question.First, I am attaching the source code for the environment I am testing.
When writing code as shown above, accessing the Page always triggers the server to execute prefetch, which then waits for the duration specified by the delay time in the API fetch function.
What I expected was that after the initial prefetch, when leaving and re-entering the page, it wouldn't re-fetch because it uses react-query's cached data. Is this an unavoidable behavior because RSC always renders anew in an SSR environment?
My knowledge is quite limited, so I may have written the code incorrectly. I need help with this.
Thank you to everyone who took the time to read this long post.
Beta Was this translation helpful? Give feedback.
All reactions