Error: NextRouter was not mounted.
next/router’s useRouter was used inside the App Router (app/ directory), which uses next/navigation instead.
Seen on:
React
Meaning
The pages router and the App Router have different hooks. In app/ use useRouter, usePathname and useSearchParams from next/navigation.
Common causes
- Importing useRouter from 'next/router' in app/
- Shared components used by both routers
⚡ Quick fix
- Import from 'next/navigation' in the App Router
- Replace router.query with useSearchParams/useParams
Detailed fix by platform
React
import { useRouter, usePathname } from 'next/navigation';
How to diagnose
- Router — app/ or pages/?
- Import — Which module?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026