I have login and Register page but the nav and the footer appears on all page. I dont know how to make the nav and footer not to appear in the login and register page. In Next 12, i usually used the getLayout
function but in next 13 there is no component props in the layout page. How can i go about it?
2
Answers
You must use a different layout to your login and register pages.
Here is the Docs https://nextjs.org/docs/app/building-your-application/routing/pages-and-layouts#nesting-layouts
But in resume you only need to create your file in the same context folder:
This way the pages login and register will use the same layout, and any other page inside dashboard/ have the same layout.
In nextjs13 you have a
layout.js
file you can use but as per your use case you want different layout for login, register and a different one for other routes.Steps to follow
(folderName)
. You can name your folder anything but don’t remove parenthesis.For reference – https://nextjs.org/docs/app/building-your-application/routing/route-groups
Note: In the above scenario for dashboard you will have content from the layout.js inside group but you will also have content from app/layout.js
If you don’t want that then delete layout.js from app/ and create a route group for login and register and a layout.js inside that route group separately for login and register. Check multiple root layout in above nextjs docs link