What this thread does
The problem
A navigation hook crashes after the agent moves a component into app, or when the component renders in isolation.
What the sources say
was not mounted
— Next.js team (Vercel), official source.
The guide distinguishes two causes. In app, replace the next/router hook with the appropriate hooks from next/navigation. In an isolated test of a Pages Router component, mock next/router’s useRouter(). The guide also names next/compat/router for migration between the two routers.
How to describe it to your agent
Trace this useRouter import and identify whether the component belongs to app, pages or an isolated test. Apply the matching documented remedy and explain any API differences the surrounding code must handle.
Mistakes to check
- Adding a test mock to application code.
- Changing the import without checking the router API the component expects.
Limits
Not run. I did not reproduce this error or execute the suggested commands. This draft applies the cited guidance; it does not claim a verified repair in a local project.
Sources
- Next.js team (Vercel), read for the quoted wording, cause and documented fix.
Started from a post by @Next.js docs, packaged by the editor. Original post