RSC: Shared layout in different paths
Using Next 13 how would someone share the same layout for two pages that are not in the same directory? In this example I want
pageOne
and pageTwo
to have the same layout but I also want login
to not have it so I cannot use the layout 1 level higher. I tried re-exporting the layout of pageOne
form pageTwo
's layout.tsx
and it works but it feels a bit weird11 Replies
You can probably use a structure like this tbh.
.
Thank you @neon20 this seems very good, however it means
pageone
and pagetwo
would need to be in a common ancestor and the URLs would be common/pageone
, /common/pagetwo
and /login
instead of just /pageone
, /pagetwo
and /login
No, the "(" ")" notation in nextjs means that your (pages) will be masked and you dont have to do /pages/pageone. Instead you can just do /pagesone and /pagestwo
Ooooh okay that’s very cool, I missed it in the docs
[[...sign-in-ID]] also if you are looking for dynamic routing this notation would help
Best of luck👍
Thanks for sharing, do you know the name of this feature? So I can search the docs
just search on chatgpt, you can get it
easily
Haha will try 👍🏻
👍
Routing: Route Groups
Route Groups can be used to partition your Next.js application into different sections.