What is the difference between next/router and next/navigation?
P粉9463361382023-10-30 16:44:55
0
1
1210
In Next.js, I know that both next/router and next/navigation have a useRouter() hook, but the objects returned are different. Why does Next.js have the same hook on both routing packages?
Quoted from
docuseRouter
fromnext/router
will be used in the pagesfolder, in Next.js Set the initial way of routing. Starting with
v13 they introduced a new directory calledapp
(used when you say yes to the last question shown in the image below ), built on
Server Component where you can define routes differently and use useRouterfrom
next/navigation:: As shown in the picture on the left, you can select the router type for which you want to obtain relevant documents: