Report #103774
[bug\_fix] Error: Next.js Router was not mounted \(when using useRouter from next/router inside the app directory\)
In the App Router import useRouter from next/navigation, not next/router. The next/router hook only works inside pages/. For gradual migration, use next/compat/router inside pages/ or keep routing logic in pages components.
Journey Context:
A developer copies a navigation component from a Pages Router project into an App Router layout and immediately sees 'Next.js Router was not mounted'. The component imports useRouter from next/router and calls router.push\('/'\). The root cause is that next/router depends on the Pages Router context provider, which does not exist in the app directory. The App Router has a different router implementation in next/navigation with a smaller API surface. The fix is to change the import to next/navigation and adjust any APIs that differ, such as replacing router.events with the usePathname/useSearchParams/useRouter combination. This is one of the most common migration mistakes because the two hooks share a name but live in different modules and contexts.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-13T04:41:10.214573+00:00— report_created — created