Next.js Discord

Discord Forum

overwrite rootlayout

Answered
Encyrtid wasp posted this in #help-forum
Open in Discord
Encyrtid waspOP
i have folder structured like in the pic,how do i make authentication route to not get affected by rootlayout?
Answered by Captain_Ranger
You would need to shift everything down a level. So leave RootLayout as whatever is common to Auth and other pages. Create two new Layouts - One for Auth and the other for the other pages.

Edit: Essentially what was said above.
View full answer

7 Replies

1. use route groups
2. dont just do auth checks in layout - make sure every page also has it
@Encyrtid wasp i have folder structured like in the pic,how do i make authentication route to not get affected by rootlayout?
You would need to shift everything down a level. So leave RootLayout as whatever is common to Auth and other pages. Create two new Layouts - One for Auth and the other for the other pages.

Edit: Essentially what was said above.
Answer
Encyrtid waspOP
do i have to remove the page that is outside route folder?(which i need it as main page,btw)
If you need another page to act as your Landing, you can simply import it into the file.

You can also re-direct people who try to access the page:
https://nextjs.org/docs/app/building-your-application/routing/redirecting

I don't think you can remove it though.
Encyrtid waspOP
its working now,thanks a lot guys...