Deviopath › Next.js

Show the Current Path

Easy · Navigation

The usePathname() hook from next/navigation returns the current URL path (without the query string), like "/about". It is a Client Component hook, and the component re-renders when the path changes.

Show the current path in the <p> as You are on: <pathname>, for example You are on: /about. It must update when a link is clicked.

Next: Route Groups in the URL