Prefetch route with its data, not only loading.js #51821
AnandChowdhary
started this conversation in
Ideas
Replies: 2 comments
-
We are looking for this feature as well. How would one go about implementing this? |
Beta Was this translation helpful? Give feedback.
0 replies
-
You can do this by making your own |
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.
-
Goals
Next.js allows you to prefetch a route including its data.
Background
Currently, if you have a dynamic route that fetches data (e.g.,
/users/[user_id].jsx
fetches a user's profile) and you try to prefetch the route, Next.js will only prefetch theloading.jsx
and not make thefetch
request to get the data. Only when you navigate to the page will a request be made, meaning that unless this data is cached you are guaranteed to see the loading suspense screen with no way to circumvent this.As per Linking and Navigating § Prefetching:
Proposal
Add a property to allow fetching data, e.g.,
prefetchData
, which isfalse
by default (current behavior):This will not only prefetch the layout, but also loads its data.
Beta Was this translation helpful? Give feedback.
All reactions