How to render a navbar in all pages besides the register and login page optimally?
Answered
Burmese posted this in #help-forum
BurmeseOP
My website has a navbar and I want it to be displayed on multiple pages so I thought that it is a good idea to put it in layout.js. But I don't want to display it on the register and login page so I am trying to figure out the best way of doing so.
I tried to get the pathname that the user is trying to access but in that case, I would have to make the layout a client component. This in turn essentially turns all pages into client components to my understanding. I believe it's not worth it and it would be better to just paste the navbar in all components manually and not have it in the register and login page. Is there any other better way of doing so? Thank you for your time!
I tried to get the pathname that the user is trying to access but in that case, I would have to make the layout a client component. This in turn essentially turns all pages into client components to my understanding. I believe it's not worth it and it would be better to just paste the navbar in all components manually and not have it in the register and login page. Is there any other better way of doing so? Thank you for your time!
Answered by B33fb0n3
you can use [route groups](https://nextjs.org/docs/app/building-your-application/routing/route-groups) to group specific layouts for specific pages. Like that you can have for example a navbar in all pages, but not in register or login page
3 Replies
@Burmese My website has a navbar and I want it to be displayed on multiple pages so I thought that it is a good idea to put it in layout.js. But I don't want to display it on the register and login page so I am trying to figure out the best way of doing so.
I tried to get the pathname that the user is trying to access but in that case, I would have to make the layout a client component. This in turn essentially turns all pages into client components to my understanding. I believe it's not worth it and it would be better to just paste the navbar in all components manually and not have it in the register and login page. Is there any other better way of doing so? Thank you for your time!
you can use [route groups](https://nextjs.org/docs/app/building-your-application/routing/route-groups) to group specific layouts for specific pages. Like that you can have for example a navbar in all pages, but not in register or login page
Answer