Next.js Discord

Discord Forum

Need help nesting layouts within folders

Turkish Angora posted this in #help-forum
Open in Discord
Turkish AngoraOP
So to my understanding I can nest different layouts within different folders, and whenever the child page is routed to, the parent layout in that folder will be applied.

My question is do I still need a layout component “layout.tsx” located in the root of my app directory? Or can I only use nested layouts within specific folders that apply to each individual page, without having a root layout document.

My gut feeling is no and that I still need the root layout file but I wanted further clarification. If anyone can answer this that would be awesome! Thanks for your help!

1 Reply

Turkish AngoraOP
Nevermind, answered my own question with documentation lol. To anyone else with the same question, YES you do need the root layout.tsx in your app directory, you cannot only have sub-layouts nested in folders with no root layout.