Hi devs, in this article we will learn which solution is better for us.
So many developers facing issue while using useRouter in next JS.
import { useRouter } from "next/router";
const router = useRouter();
The above import is not working in next JS when we are using app router.
So as documentation next js allow useRouter from next/navigation in App Router.
Here is the way of importing the useRouter in App Router.
import { useRouter } from "next/navigation";
const router = useRouter();
Thank you for reading. That’s all for today.
Top comments (0)