#Router

1 messages · Page 1 of 1 (latest)

scenic raft
#

@eternal saddle

What do you get if you just render the currentRoute inside the component?

eternal saddle
#

I'm creating a Navbar and adding a className if it's active Link

#

If I check the router, it returns this value:

scenic raft
#

It should work, I am doing it exactly the same way in Next 13.

It is possible the issue comes from something higher up.

How are you importing useRouter and how are you implementing it?

Can you share more relevant code?

eternal saddle
#

I'm importing the useRouter now from next/navigation since I'm getting an error that the NextRouter is not mounted if I'm importing it from next/router.

I've added the "use client" in the component since I use useState in it.

#

Error: NextRouter was not mounted. https://nextjs.org/docs/messages/next-router-not-mounted at Navbar (./app/Navbar.jsx:24:74)
Exact error on my end

scenic raft
#

Try import { useRouter } from "next/router"

#

And try removing "use client"

#

It could be that it works differently if you use the app directory

eternal saddle
scenic raft
#

Yeah, the app directory feature is considered a beta release

#

It can have some bugs and issues

#

You can use Next 13 without the app directory, though

eternal saddle
# scenic raft You can use Next 13 without the app directory, though

I'm actually exploring the new features of Next 13 that's why I'm using these experimental. Researched further and found this:

https://github.com/vercel/next.js/issues/43585

So basically, the NextRouter is not mounted is already a common issue. Might need to downgrade to 13.0.2 for the meantime as mentioned in the post.

GitHub

Verify canary release I verified that the issue exists in the latest Next.js canary release Provide environment information I am getting this error that most people get only inside the app folder. ...