Report #17181
[bug\_fix] Error: NextRouter was not mounted \(when using useRouter in App Router\)
Change the import from \`next/router\` to \`next/navigation\`. In the App Router, the \`useRouter\` hook is imported from \`next/navigation\` and returns a different, lighter interface tailored for the new routing system.
Journey Context:
Developer is migrating a page from the Pages Router to the App Router \(\`pages/dashboard.tsx\` → \`app/dashboard/page.tsx\`\). They copy the existing component code which imports \`useRouter\` from \`next/router\`. Upon starting the dev server, the component crashes with 'NextRouter was not mounted'. Developer checks that they are inside the \`app\` directory and that the component is a Client Component \(has 'use client'\). They search the error and find references to the App Router using a different hook. They change the import line to \`import \{ useRouter \} from 'next/navigation'\`. The error disappears and navigation works. They realize the two routers are completely separate systems.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T04:44:39.860466+00:00— report_created — created