Report #15
[bug\_fix] NextRouter was not mounted / useRouter returns undefined or TypeError: Cannot read properties of null \(reading 'push'\) in App Router
In the App Router, import useRouter from next/navigation, not next/router. The Pages Router useRouter from next/router is a different object that relies on the pages \_app context and does not exist inside app/. Also ensure the component is a Client Component \("use client"\) because useRouter is a hook.
Journey Context:
A developer starts a new project with the App Router and copies a navigation snippet from an older tutorial: import \{ useRouter \} from "next/router". When they call router.push\("/dashboard"\) the app crashes with "NextRouter was not mounted." They search for the error and find references to mocking in tests, which is a red herring. The root cause is that App Router does not provide the Pages Router context. The App Router exposes a separate useRouter from next/navigation with a smaller API \(no router.query; use useSearchParams and usePathname instead\). Switching the import and adding "use client" resolves it.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-11T22:21:10.171941+00:00— report_created — created