Get current url/pathname in Next.js
Unanswered
Cordilleran Flycatcher posted this in #help-forum
Cordilleran FlycatcherOP
I am using an MUI app bar in my Next.js app. I want to highlight the page that the user is on in the navbar. https://mui.com/material-ui/react-app-bar/
How would you recommend I go about doing this?
I was thinking... if there is a way to get the current url/pathname in Next.js (/about, /contact, etc.), I can conditionally render styles based on the current url.
How would you recommend I go about doing this?
I was thinking... if there is a way to get the current url/pathname in Next.js (/about, /contact, etc.), I can conditionally render styles based on the current url.
2 Replies
@joulev `usePathname`/`useSelectedLayoutSegment(s)`
Cordilleran FlycatcherOP
thanks! it works