layout for subroutes
Answered
Mike posted this in #help-forum
MikeOP
Hello, i have a page with an home page and /dashboard routes.
What is the best practice to create an layout for the subroutes like /dashboard /dashboard/users and so one.
Ive already created the layout. How i can implement it only in the subroutes?
What is the best practice to create an layout for the subroutes like /dashboard /dashboard/users and so one.
Ive already created the layout. How i can implement it only in the subroutes?
Answered by !=tgt
like this
.
└── src/
└── app/
├── page.tsx
├── layout.tsx
└── dashboard/
├── page.tsx
└── (subroutes)/
└── layout.tsx
└── users/
└── page.tsx13 Replies
in a folder
who's name is enclosed in parentheses (so that it's not part of the route)
and then put the layout in the root of that folder
like this
.
└── src/
└── app/
├── page.tsx
├── layout.tsx
└── dashboard/
├── page.tsx
└── (subroutes)/
└── layout.tsx
└── users/
└── page.tsxAnswer
MikeOP
Thank you very much 🙂
And where I need to define this layout? In dashboard/page.tsx?
Ahh, I only need to define it in the old version.
I understand
@Mike I understand
make sure to mark the answer with the bot :)
MikeOP
Yes 🙂 but one question. Why I can’t put it in the /dashboard folder? Because the default page should have the layout too?
yeah that's why
MikeOP
Okay.