Skip to the page

Rendering strategies · mid

Pages Router: getServerSideProps, getStaticProps and migrating

Interviewers still ask Pages Router data functions: getServerSideProps runs on every request, getStaticProps at build (plus revalidate for ISR), getStaticPaths lists dynamic pages with a fallback mode; know how each maps to the App Router and how to migrate route by route.

The notes

What you must know

  • getServerSideProps({ params, query, req, res }) runs on the server for every request and returns { props }, { redirect } or { notFound: true }. App Router: an async Server Component reading request data (dynamic rendering).
  • getStaticProps runs at build; revalidate: 60 makes it ISR. App Router: cached data ("use cache" + cacheLife with Cache Components, or fetch(url, { next: { revalidate: 60 } }) / cache: "force-cache" in the previous model).
  • getStaticPaths returns paths and fallback: false (404 for others), true (fallback UI, then generate), "blocking" (wait for SSR). App Router: generateStaticParams + dynamicParams; with Cache Components, fallback: true maps to Partial Prefetching (App Shell first) and "blocking" to awaiting params outside Suspense.
  • _app and _document become the root layout.tsx; next/head becomes the Metadata API; pages/api/* becomes route.ts Route Handlers; next/router becomes next/navigation hooks (no query, no asPath, no isFallback); _error/404 become error.tsx/not-found.tsx.
  • Pages are Client Components in pages/; in app/ they are Server Components by default.
  • Incremental migration: both routers coexist; move leaf routes first; navigation between the two routers is a hard navigation; keep _app/_document until done.
  • The Pages Router is still supported, but Cache Components, Partial Prerendering and Server Actions are App Router only.
  • Careful: Next 15+ fetch is NOT cached by default, even though some older migration examples say it defaults to force-cache.

The red pen

Common traps: mistake → fix

  • Mistake: "getServerSideProps runs in the browser on client navigation"

    Fix: it always runs on the server; the client fetches its JSON.

  • Mistake: "fallback: true and blocking are the same"

    Fix: true shows a fallback first; blocking waits for the full HTML.

  • Mistake: "Migrate everything in one big PR"

    Fix: migrate route by route.

Easy to hard

Questions interviewers ask, easy to hard

  1. Explain getStaticProps, getServerSideProps and getStaticPaths.
  2. What does each fallback value do?
  3. What replaced them in the App Router?
  4. We have a large Pages Router app. Would you migrate, and how?
  5. What happens when a user navigates between an App Router page and a Pages Router page?

Practise

Practise with these questions

Explain it out loud

Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.

Practise by voice

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview