Next.js Discord

Discord Forum

"NextRouter was not mounted" in a client component

Answered
Manx posted this in #help-forum
Open in Discord
Avatar
ManxOP
"use client"
import { useRouter } from "next/router";

IDK, how to debug this one!

I found a (Nextjs page)[https://nextjs.org/docs/messages/next-router-not-mounted] that assumes that I'm using that routing method in a testing environment, which is not true.
Answered by Double-striped Thick-knee
if you're using app directory. import it from "next/navigation"
View full answer

2 Replies

Avatar
Double-striped Thick-knee
if you're using app directory. import it from "next/navigation"
Answer
Avatar
ManxOP
My Bad, I just tried it, and it seems to solve the issue. Thanks.