The last four chapters taught Next.js 16 as if every app started there. Most don't. You'll join codebases on 14 with implicit caching, on 15 halfway through the async request API migration, and on the Pages Router, which was Next.js's only router from its 2016 launch until 2023, still ships in Next.js 16, and still runs a large share of production Next.js. Interviewers ask about it because their apps use it, or because they want to know whether you understand what the App Router replaced and why.
This is a reference chapter: what changed in each major version, the Pages Router's data functions mapped to their App Router equivalents, and how to migrate.
The problem: "which Next.js is this?"#
Three snippets, all real Next.js, all fetching a book:
export async function getServerSideProps({ params }) {
return { props: { book: await getBook(params.id) } };
}export default async function Page({ params }: { params: { id: string } }) {
const book = await fetch(`https://api.example.com/books/${params.id}`).then((r) => r.json());
// ...cached forever by default in 14, unless you opt out
}export default async function Page({ params }: PageProps<"/books/[id]">) {
const { id } = await params; // params is a Promise
const book = await getBook(id); // uncached unless getBook says "use cache"
}Same feature, three mental models. Reading a codebase well starts with knowing which one you're in.
What changed: 14, 15, 16#
| Next.js 14 (Oct 2023) | Next.js 15 (Oct 2024) | Next.js 16 (Oct 2025) and 16.x | |
|---|---|---|---|
| React | 18 | 19 for the App Router; Pages Router supports 18 and 19 | 19.2 features; 16.4 ships React 19.3 |
| Minimum Node.js | 18.17 | 18.18 | 20.9 |
fetch caching | Cached by default | Not cached by default | Not cached; opt in with "use cache" (Cache Components) |
| GET Route Handlers | Cached by default | Not cached by default | Follow the same prerendering model as pages under Cache Components |
| Client Router Cache | Reuses dynamic segments 30 s, static 5 min | Doesn't reuse page segments by default (staleTimes.dynamic 0) | Rewritten: per-segment prefetching, layout deduplication; stale time from cacheLife |
params, searchParams, cookies(), headers() | Synchronous | Async, with a temporary sync shim and warnings | Async only |
| Caching model | Implicit: four layers | Same layers, cautious defaults; "use cache" experimental | Cache Components (cacheComponents: true), default in new apps since 16.4 |
| PPR | Preview | Experimental (experimental.ppr) | Flag removed; it's how Cache Components renders |
| Middleware | middleware.ts, Edge runtime | Same; Node.js runtime for middleware stable in 15.5 | proxy.ts on Node.js; middleware.ts deprecated |
| Bundler | webpack; Turbopack dev in beta | Turbopack stable for next dev | Turbopack default for dev and build |
| Server Actions | Stable | Stable, with unguessable ids and dead-code elimination | Plus updateTag and refresh |
| React Compiler | Not available | Experimental option | reactCompiler: true stable, off by default |
| Other | next.config.ts, <Form> from next/form, after() (stable in 15.1), instrumentation.ts stable | next lint removed, AMP removed, serverRuntimeConfig/publicRuntimeConfig removed, default.tsx required for parallel slots, next/image default changes |
And the 16.x minor releases, which changed more than most majors:
- Next.js 16.2 Adapters stable (deploy anywhere through a build adapter),
transitionTypeson<Link>,next start --inspect, faster Server Components payload parsing. - Next.js 16.3 Instant Navigations: Partial Prefetching (
partialPrefetching: true), Instant Insights in devtools, a Playwrightinstant()helper, App Shells for unlisted ISR params,catchErrorandretryfor error boundaries, root params fromnext/root-params, disk-cached builds. - Next.js 16.4 React 19.3, Cache Components on by default in
create-next-app(with Partial Prefetching now treated as part of the model),ensureStatic,navigation()andprefetch()fromnext/cache,next upgrade --agent. The 16.4 post says Cache Components becomes the default in Next.js 17.
The arc is worth being able to say in one breath: 14 cached everything implicitly and surprised people; 15 turned the implicit caching off; 16 replaced it with explicit, composable caching and made partial prerendering the rendering model.
The Pages Router#
Before the App Router (stable in 13.4, May 2023), every Next.js app used pages/. Each file is a route: pages/books/[id].tsx serves /books/42. Pages are ordinary React components rendered on the server and hydrated on the client, so every component is a Client Component in today's terms; there are no Server Components. Data comes from special functions exported next to the page, which run only on the server and pass props in.
getServerSideProps: render per request#
import type { GetServerSideProps, InferGetServerSidePropsType } from "next";
export const getServerSideProps = (async ({ params, req, query }) => {
const book = await getBook(params!.id as string);
if (!book) return { notFound: true };
if (book.moved) return { redirect: { destination: `/books/${book.newId}`, permanent: true } };
return { props: { book } };
}) satisfies GetServerSideProps;
export default function BookPage({ book }: InferGetServerSidePropsType<typeof getServerSideProps>) {
return <h1>{book.title}</h1>;
}Runs on every request, on the server, with access to the request (req, res, query, params, cookies through req). Returns props, notFound or redirect. On client-side navigations, Next.js calls it through a JSON endpoint and renders the page with the result. App Router equivalent: an async Server Component that reads uncached data or cookies(), inside Suspense.
getStaticProps and getStaticPaths: render at build time#
import type { GetStaticPaths, GetStaticProps } from "next";
export const getStaticPaths = (async () => {
const popular = await getPopularBooks(200);
return {
paths: popular.map((b) => ({ params: { id: b.id } })),
fallback: "blocking", // or false, or true
};
}) satisfies GetStaticPaths;
export const getStaticProps = (async ({ params }) => {
const book = await getBook(params!.id as string);
if (!book) return { notFound: true };
return { props: { book }, revalidate: 3600 }; // ISR: rebuild at most hourly
}) satisfies GetStaticProps;getStaticProps runs at build time. getStaticPaths lists which dynamic paths to build, and fallback decides what happens for the rest:
false: any other path is a 404."blocking": the first request for an unlisted path waits for the server to render it (like SSR), then it's cached as static.true: the first request gets a fallback version of the page immediately (router.isFallbackistrueand props are empty), the page renders in the background, then the browser swaps in the real props.
Returning revalidate: N turns on Incremental Static Regeneration, the feature Next.js introduced in 9.5: after N seconds, the next request still gets the cached page and triggers a background rebuild. For on-demand ISR, an API route calls res.revalidate("/books/42").
The mapping to the App Router:
| Pages Router | App Router, Next.js 16 with Cache Components |
|---|---|
getServerSideProps | Async Server Component reading uncached data or runtime APIs, inside Suspense |
getStaticProps | Async Server Component whose data completes at build time, or is in "use cache" |
revalidate: 3600 | cacheLife("hours") (or a custom profile) in the "use cache" scope |
res.revalidate(path) | revalidatePath(path), or better, tags with updateTag / revalidateTag |
getStaticPaths | generateStaticParams |
fallback: true | Since 16.3, unlisted params get the App Shell instantly and upgrade in the background |
fallback: "blocking" | ensureStatic = "navigation" makes the first request wait for the complete static result |
fallback: false | notFound() for unknown params (dynamicParams = false in the previous model) |
notFound: true / redirect | notFound() / redirect() from next/navigation |
pages/api/* | app/**/route.ts Route Handlers, or Server Actions for your own forms |
_app.tsx | app/layout.tsx (root layout) |
_document.tsx | The <html> and <body> in the root layout |
next/head | metadata / generateMetadata |
useRouter from next/router | useRouter, usePathname, useSearchParams from next/navigation |
getInitialProps (legacy) | Not supported in app/ |
API routes#
import type { NextApiRequest, NextApiResponse } from "next";
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
if (req.method === "POST") {
const book = await insertBook(req.body);
return res.status(201).json(book);
}
res.status(200).json(await getBooks());
}Node-style req and res, one default export handling every method. The App Router's Route Handlers use Web Request and Response with one export per method.
_app and _document#
pages/_app.tsx wraps every page: global CSS imports, providers, persistent layout. It receives Component and pageProps and must render <Component {...pageProps} />. pages/_document.tsx customizes the HTML shell, rendered only on the server, with Html, Head, Main and NextScript from next/document. There are no nested layouts in the Pages Router; per-page layouts are a pattern (a getLayout function on the page component) rather than a framework feature, and they don't keep server data separate per segment.
getInitialProps#
The oldest data API, from before 9.3. It runs on the server for the first load and in the browser on client navigations, so its code ships to the client and must work in both places. Using it in _app disables Automatic Static Optimization for every page. You'll see it in old codebases; the answer to "should we use it" is no.
Migration paths#
Pages to App Router. Both directories work in the same app, so migrate route by route. A URL can't be defined in both, so you move a page by deleting it from pages/ and creating it in app/. Usual order: create app/layout.tsx from _app and _document, move leaf pages first, turn getServerSideProps and getStaticProps into data fetched in Server Components, replace next/router with next/navigation, then move API routes that your own UI calls into Server Actions. Components that use hooks or browser APIs need "use client". Navigating between a Pages route and an App route is a full page load, not a soft navigation, so migrate sections that users move between together.
14 to 15. Run npx @next/codemod@canary upgrade latest; it includes the async request API codemod (next-async-request-api). Then audit caching. A route with no request-time APIs is still prerendered in 15, so its fetch runs once at build as before. The change bites on dynamic routes (anything reading cookies(), headers() or searchParams): in 14 their fetch calls were served from the Data Cache, and in 15 they hit the upstream on every request. GET Route Handlers are no longer cached either. That can raise load on your APIs a lot. Add cache: "force-cache" or next: { revalidate } deliberately. Upgrade React to 19 for the App Router.
15 to 16. The same upgrade codemod, plus: Node.js 20.9+, remove remaining synchronous request API access, rename middleware.ts to proxy.ts (codemod middleware-to-proxy), add the second argument to revalidateTag (or switch to updateTag in actions), add default.tsx to every parallel slot, replace next lint with ESLint or Biome directly, replace runtime config with environment variables, check custom webpack config against Turbopack, and drop unstable_ from cacheLife and cacheTag. Since 16.4, npx next@canary upgrade --agent=latest prepares version-specific guidance for a coding agent.
Previous model to Cache Components. A separate step, done on 16. Turn on cacheComponents and partialPrefetching, then work through the build errors: each one is a component reading uncached data outside Suspense. Wrap it in Suspense or move the data into "use cache" with an explicit cacheLife. Delete dynamic, revalidate, fetchCache, dynamicParams and runtime segment exports. Replace unstable_cache and fetch cache options with "use cache".
Pitfalls#
Check your understanding#
pages/books/[id].tsx uses getStaticPaths returning only /books/1 and /books/2, and getStaticProps with revalidate: 60. A user visits /books/3, which exists in the database. What do they see with fallback: false, fallback: "blocking" and fallback: true? What does the second visitor to /books/3 see?
A Pages Router page uses getStaticProps with revalidate: 3600. What's the closest equivalent in a Next.js 16 app with Cache Components?
After upgrading from Next.js 14 to 15 with no code changes, the API behind your product pages gets far more traffic. What's the most likely cause?
An interviewer asks: "We have a large Pages Router app on Next.js 13. How would you get it to the App Router on Next.js 16?"
Interview angle
Next.js 14 cached aggressively and implicitly: fetch, static routes and GET handlers by default. Next.js 15 turned that off and made params, searchParams, cookies and headers async. Next.js 16 replaced implicit caching with Cache Components and "use cache", made partial prerendering the rendering model, renamed middleware to proxy.ts, and made Turbopack the default; 16.3 added Instant Navigations, and 16.4 turned Cache Components on for new apps. The Pages Router, still supported, fetches with getServerSideProps per request and getStaticProps with revalidate for ISR, and each maps to Server Components, cacheLife and generateStaticParams in the App Router.
What changed between Next.js 14, 15 and 16?
In the Pages Router, what's the difference between getServerSideProps and getStaticProps?
How do Pages Router concepts map onto the App Router?
What's the biggest risk when upgrading a Next.js 14 App Router app to 15?
Recap#
- Next.js 14 cached
fetch, routes and GET handlers by default; 15 madefetch, GET handlers and client page segments uncached by default and made request APIs async; 16 introduced Cache Components,proxy.ts, Turbopack by default, and async-only request APIs. - 16.2 stabilized adapters, 16.3 added Instant Navigations and Partial Prefetching, and 16.4 turned Cache Components on for new apps and added
ensureStatic. The 16.4 post says Next.js 17 is planned to make Cache Components the default. - The Pages Router uses
getServerSideProps(per request),getStaticPropswithrevalidate(build time plus ISR),getStaticPathswithfallback, API routes,_appand_document. Every component is a Client Component there. - Each maps to an App Router feature: Server Components with uncached or cached data,
cacheLife,generateStaticParams, Route Handlers or Server Actions, and the root layout. - Migrate incrementally: upgrade the framework first, move routes from
pages/toapp/in sections, then adopt Cache Components and fix its build errors.
Sources#
- nextjs.org blog: Next.js 14, Next.js 15, Next.js 16, Next.js 16.2, Next.js 16.3, Next.js 16.4
- nextjs.org: Upgrading to 15, Upgrading to 16, Migrating from Pages to App Router, Caching in Next.js 14
- nextjs.org (Pages Router): getServerSideProps, getStaticProps, getStaticPaths, ISR, API Routes
- Facts checked November 24, 2026.