Next 13 updates for useRouter

Category: javascript
By: jeremy-one

Replace router with navigation

import { useRouter } from 'next/router'; import { usePathname } from "next/navigation";

We also need to replace useRouter with usePathname

const router = useRouter(); const pathname = usePathname();

And when using as a link remove router

className={router.pathname == "/" ? "active" : ""} className={pathname == "/" ? "active" : ""}