Get URL pathname in nextjs
If you want to access the router object inside any functional component in your app, you can use the useRouter hook, here’s how to use it: import { useRouter } from ‘next/router’ export default function ActiveLink({ children, href }) { const router = useRouter() const style = { marginRight: 10, color: router.pathname === href ? … Read more