Report #16343
[bug\_fix] useRouter returns undefined or lacks methods like push in Next.js App Router
Import \`useRouter\` from \`next/navigation\` instead of \`next/router\`. Note that the App Router \`useRouter\` has a different API \(e.g., \`router.push\` works but \`router.query\` is replaced by \`useSearchParams\`\). Root cause: \`next/router\` is the legacy singleton router for Pages Router; App Router uses a new navigation system in \`next/navigation\` that integrates with the React Server Components architecture.
Journey Context:
Developer is migrating an existing project from Next.js 12 \(Pages Router\) to Next.js 14 \(App Router\). They copy over a navigation component that uses \`import \{ useRouter \} from 'next/router'\` and calls \`router.push\('/dashboard'\)\`. In the App Router environment, the component compiles but at runtime, \`router\` is \`undefined\` or lacks the \`push\` method, throwing "Cannot read properties of undefined \(reading 'push'\)". Developer searches the error and finds GitHub issues indicating that App Router requires a different import path. They change the import to \`next/navigation\`, which provides a compatible \`useRouter\` hook designed for the App Router's navigation state. The push method works as expected, though they note that query parameters are now accessed via \`useSearchParams\(\)\` instead of \`router.query\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T02:24:26.593331+00:00— report_created — created