Migrating from the pages directory:
- The new useRouter hook should be imported from next/navigation and not next/router
- The pathname string has been removed and is replaced by
usePathname() - The query object has been removed and is replaced by
useSearchParams()
router.events is not currently supported.
Here is the solution: https://beta.nextjs.org/docs/api-reference/use-router