Question presented to candidate: "Next.js has two routers. What is the difference, which one would you choose for a new project, and can they coexist?"
What a strong answer should cover:
- Pages Router (
pages/): every file is a route, data via getServerSideProps and getStaticProps, all components are client components that also ship to the browser. - App Router (
app/): folders are routes and only page files are public; React Server Components by default; nested layouts, loading and error files, streaming, Server Actions. - The App Router is the recommended choice for new projects; the Pages Router is still supported.
- Both can live in one project, which allows incremental migration; navigation between them is a full page load.
- Pages Router props are serialized into
__NEXT_DATA__; the App Router sends an RSC payload of rendered output.
Clarifying questions expected:
- "New project or existing app?" β new projects use the App Router.
- "Which libraries depend on next/router or _app?" β they influence the migration order.
Code / implementation expected: Yes β the same page in both routers.