Question presented to candidate: "We have a large Pages Router app. How would you plan the migration to the App Router without a big-bang rewrite?"
What a strong answer should cover:
- Both routers work in one app, so migrate incrementally, route by route; a path must not exist in both.
- Start with the root layout (
app/layout.tsxreplaces_appand_document), then move low-risk pages. - Replace data functions with Server Component fetching,
next/routerwithnext/navigationhooks,next/headwith the Metadata API, and API routes with Route Handlers when convenient. - Navigation between the two routers is a hard navigation (full page load) and Link does not prefetch across them, so migrate related sections together.
- Use codemods for mechanical changes and upgrade Next.js first so both routers run on the same version.
Clarifying questions expected:
- "Which sections are most self-contained?" β they migrate first.
- "Which libraries rely on next/router or _app providers?" β they need Client Component wrappers.
Code / implementation expected: Yes β a root layout replacing _app and _document, and a page conversion.