Targeting window.location.pathname in Next.js

Do you know how to target window.location.pathname in NEXT.JS ?

I have this code and next.js shows me nice red err

const path = window.location.pathname
     console.log(path) // here I am getting pathname 

Than

         {  
            path === '/product' ? <p className='mt-2'>Products</p> :
            path === '/contact' ? <p className='mt-2'>Contact</p> :
            path === '/cart' ? <p className='mt-2'>Cart</p> :
            <p className='mt-2'>Home</p>
          }