Preload whole content (not just prefetch) #84825
Unanswered
toitzi
asked this question in
App Router
Replies: 1 comment 2 replies
-
Could you try
|
Beta Was this translation helpful? Give feedback.
2 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.
-
I have a nextjs 16 app with a page which displays a table.
The data uses the new "use cache" function to load the data from an external database server. All works just fine, data is fetched, cached on subsquent requests. My problem is i have some "hot pages" i know will be opend in my app > 90%, i also have some cases where when i user hovers a link, i know for a very high certainy that the link will be clicked. In those cases i want to preload the whole page (including the data). Using prefetch for links (enabled by default) only loads the Layout to first loading boundary (which is documented and what i would expect and what is fine in most cases). However in some cases like this one i want to avoid showing the loading.tsx and preload the WHOLE page in advance. I have not found a way to do that, is there a way to do this in NextJS (because it is possibe with for example Tanstack Query) and would imho improve user experience for those cases, since the data is prefetched early enough an usually already available when the user clicks the link. Using prefetching with tanstack query avoids the loading.tsx flash and therefore the "second layout shift" that would happen from it, but i would like to remove tanstack query from my project and use nextjs functionality.
I tried adding preloading to my page.tsx (server side) and also tried to prefetch manually using
router.prefetch
(or both approaches at the same time) but no matter what, the loading.tsx is always flashed it never preloads the whole page - only to the closest loading boundary.Is this possible? Can this be archived somehow? Thanks in advance.
p.s this might relate to #58261 but im not 100% sure.
Beta Was this translation helpful? Give feedback.
All reactions