Nextjs 14 global not-found with multiple root layouts
Answered
White-faced Storm-Petrel posted this in #help-forum
White-faced Storm-PetrelOP
Hi, I have this folder structure and the question is how do I use the not-found and file globally that applies to each route group? Every group has a layout.. Strangely when I add a not-found each group, it just does not work.
A global error file works as it does not require a root layout file.
A global error file works as it does not require a root layout file.
Answered by White-faced Storm-Petrel
Anyway I made a workaround for this. An ugly one but we can just hope a new version will cover this topic.
7 Replies
White-faced Storm-PetrelOP
you should be using only 1 root layout at the root of app, I see there no pros of defining html and body few times as any providera can be defined in other layouts
White-faced Storm-PetrelOP
But the documentation says I can have mulltiple root layouts.
https://nextjs.org/docs/app/building-your-application/routing/route-groups#creating-multiple-root-layouts
https://nextjs.org/docs/app/building-your-application/routing/route-groups#creating-multiple-root-layouts
This way I would be able to not import a heavy library i am using in (editor) into a route in (home)
Thats the idea.
Thats the idea.
Also I dont want to have the same navigation for example in different layouts.
You didn’t provided the code of layouts so I can only guess 😉 If you use package-based editor you still can make that using one root-layout and then other layouts in it
White-faced Storm-PetrelOP
Anyway I made a workaround for this. An ugly one but we can just hope a new version will cover this topic.
Answer