-
Notifications
You must be signed in to change notification settings - Fork 27.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<Link prefetch={false}>
in multiple root layouts just fetch, no transition
#48530
Comments
<Link prefetch={false}>
in multiple root layouts just fetch, no transition
I have the exact same issue! I have implemented my app in the same way as https://github.com/vercel/next.js/tree/canary/examples/app-dir-i18n-routing, however if I add prefetch={false} to the links they stop transitioning, only a fetch is triggered. |
Ok, I was able to solve my issue by including a root layout.js file, i.e. app/layout.js. The layout.js should do nothing except return the children. Probably the example https://github.com/vercel/next.js/tree/canary/examples/app-dir-i18n-routing needs to updated as well to contain this root layout.js file. @wonu maybe would be good to try? Here are the contents of the root layout.js file I am using:
|
@astateful You're right, I also wrote it in Expected Behavior with that meaning. I should have written more clearly :) FYI, the official docs for multiple root layouts says
I'm lost and wandering :( |
@wonu Wow I understand how you feel now, especially when the docs also write https://nextjs.org/docs/app/building-your-application/routing/pages-and-layouts#layouts
I do not have experience with using groups however, maybe my suggestion only works for dynamic routing. Either way it seems like the documentation should be more clear about when a root layout.js is required vs not. |
I have the same problem. Layout re-renders (and re-fetches) if I group things and have multiple root layouts and I have prefetch={false}. With prefetch it doesn't re-fetch but I don't want prefetch, I think this is unexpected behaviour unless I am missing something. |
#51292 fixed the issue on my end. It is available in canary |
#51292 Closes this, please upgrade to latest canary to try it again, thanks! |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
Which area(s) of Next.js are affected? (leave empty if unsure)
App directory (appDir: true), Routing (next/router, next/navigation, next/link)
Link to the code that reproduces this issue
https://stackblitz.com/edit/vercel-next-js-8g3pxu
To Reproduce
<Link href='/foo'>go to /foo</Link>
, then page moves to/foo
.<Link href='/bar' prefetch={false}>go to /bar</Link>
, then only fetch/bar
, no page move.foo
does the same thing asbar
.Describe the Bug
Clicking
<Link>
doesn't work as expected as above.Expected Behavior
Clicking
<Link>
should make page transition, not just fetching.If add root layout outside of route group or allow prefetch then the issue is not be reproduced.
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
The text was updated successfully, but these errors were encountered: