Welcome to our brand-new Next.js Comment Solving Series! 🎉 In this episode, we're tackling a real viewer's question: "How to hide the Navbar on specific pages in Next.js?"
We’ll walk you through the current layout, solve the issue using App Router features, and also explore alternate ways to implement this with Client Components. Plus, you’ll learn how to add a simple back navigation for a better user experience! ------------------------------------------------------------------------ 🚀 Boost Your Skills with these Pre-Requisite Videos:
⌛TIMELINE⏳ 0:00 - WELCOME TO NEXT.JS COMMENT SOLVING #1 0:40 - READING USER COMMENTS, WHAT WE’RE SOLVING 2:10 - HOW OUR PAGES & LAYOUT CURRENTLY LOOK 3:08 - SOLVING THAT ISSUE: Hide Navbar on Specific Pages 6:02 - ADDING BACK NAVIGATION BUTTON 7:15 - ALTERNATE SOLUTION USING CLIENT COMPONENTS 8:45 - MY MANN KI BAAT: Final Thoughts & Motivation
hello what's up guys today in this video we will see solving user comment hashtag one in our next
year series so now guys our first video is going to be on comment solving yes guys so you can see
this is our fourth video of next series where a lot of people have commented and one comment was such
that I thought maybe I should share it with you too and that is this comment
this comment you can see where basically what is told i will tell you we read layout
if you remember
for example our headers
about page
i don't know
and
and this is our home page
layout
service page
contact page
about page
route to groups in next
so this is our folder structure
and this one is the main one
and that is your app folder
this is your route group
admin folder
as it is
admin
For example, About, Contact, Service, Default Homepage, and Layout
I have kept all these in this
Now, one thing is simple
Our layout
is inside who?
If you look carefully
It is inside our users
And along with that layout, all these are with them
So, this means that whatever I will write inside this
will be applied to my About, Contact, and Service
But today, what was their doubt?
That I don't want to apply on About
I don't want to show that navbar on the About page
It is simple, isn't it?
So, what we will do
Once you have made this route group
So, we will remove About from there
I will move it outside the route group of the app
I will have to close this project so that it can be moved
So, now you will see carefully
So, now this is my folder structure
Where
This particular part
These are your users
Basically, this is my route group
This is my second group
Now, I am not going to call this a group
This particular part
I am not going to call it a group
Because, by default
If you create any other folder inside the app folder
It becomes your default page
So, if we see
This is a normal page inside the app folder
There is nothing else
And the rest is here
And the best part is
If you create a route in the route group
It does not pollute your URL
You will not even know
How you have created a folder
And you have created it for multiple users
So, if I have done this
I will run it once
Let's check it out
So, this is my home page
First of all, I want to go to the home page
And everything is fine on the home page
I want to go to the service page
Everything is fine there too
Let's say, I go to the contact page
Everything is fine there too
Now, it's time to test
Is the about page working or not
Will I be able to see this
What do you think, will you be able to see
Let's check it out
And boom guys, see
And this was their doubt
I mean, this was their query
That I don't want to show on the about page
That's it, they are not showing
But yes, you will notice one thing
How do I go back
Either I will have to
Press this button
Back button
Or else, I will have to edit the URL
But what do we want
Although their doubt was this much
But still, what will I do
We have a page on the about page
I will go here very easily
I don't need a button
Okay, I will make a button
I will add a link to it
And by the way, we have already seen this link
And that is your link
Component
And by the way, you can see
This is a link component
And very easy, just like we use anchor tag
We can use link tag
And here I just have to give
Href
And I want to give home route
Like home page
Right, like this
Now if I do this much
So you see, my home page has gone
Now if I click on this, I can easily
I can go to my home page
I don't want to show navbar
But there should be a medium
With which I can go back or home page
So I showed
Their main query
I don't want to show navbar
So I didn't show
But there is one more solution
And that is with the help of
Use path name
You can do it very easily
And that is you have to use a condition
And before telling that condition
I want to show you
You have to import
From navigation module
By default, you get a built in module
In next
In which there is a navigation
Or you can call it a package
And the most important thing
They have written something
At the top
And that is your use client
And this is very important
Next.js is all about your client components
Server components
What you can do in server component
What you can do in client component
If you know this
Then your life will be very easy
And till now we haven't read about client component
Have you seen this
Till now we haven't covered this
So how can I tell you this
So that's why I just told
Now with the help of use path name
You can easily put a condition
And that is you call this function
So you get
URL path name
And then you just say
My path name
Leave about
Else
Don't show
You can do this
I told you this alternate
When we will read about client component
Then I will tell you
But yes, if you use proud group
Still it is working
No problem
This is it for this video
And I would like
If you have more doubts
I think it will be helpful
So I will make videos like this
So that you also feel
That I am listening to you
Else
Just leave the video
No like, no comment
I will see where I feel right
I will reply
So that you feel
That someone is teaching you
And don't feel abandoned
This is it
That's all for this video
Please check out this course
And like
Share with your friends
You can share on Instagram
That I am going to start
You can make a group
You can do a lot
And next target is
8 lakh subscribers
Please do it
Till then guys thank you so much
Take care