NextRouter was not mounted ⚛️ React

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

  1. Import from 'next/navigation' in the App Router
  2. Replace router.query with useSearchParams/useParams

Detailed fix by platform

React

  1. import { useRouter, usePathname } from 'next/navigation';

How to diagnose

  1. Router — app/ or pages/?
  2. 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.