Best practice to kick off data request in RSC and using SWR on client #75664
Unanswered
yairhaimo
asked this question in
App Router
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I followed the Nextjs SPA guide which gives a pattern of using SWRConfig with a fallback in order to kick off the data fetching on the server and populating the SWR on the client thus shaving off a bit of time until the data is shown to the user and still enjoying client side caching.
That's fine if you have hardcoded keys (taken from the docs):
If i have a dynamic route i cannot use this pattern and instead i pass a promise as a prop to a client component:
The problem is that i then need to create a route handler for
/api/dummydata
which will callgetDummyData
(like in the RSC).Am I missing anything? What is the best practice in such a case?
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions