snippet

How to get current pathname with Next.js

import React from 'react'
import Link from 'next/link'
import { useRouter } from 'next/router'

const MyComponent = () => {
    const { pathname } = useRouter()

    return (
        <div>
            Pathname: {pathname} 
        </div>
    )
}

export default MyComponent