🛣️

How to chechk is home with useRouter in Next.js(React)

2021/09/12に公開

Llike this👇

{router.pathname !== '/' && (
    <div className=''>
	...
    </div>
)}

Properties of router

Here is a example that shows what are propeties of router. This url is /search?q=aaa, not / so that we can understand. So don't use asPath as this contains query, use pathname or route.

Today there is no defference between pathname and route.
https://stackoverflow.com/questions/65370486/difference-between-router-pathname-and-router-route-in-nextjs/65466725

Discussion