Skip to the solution
MediumFrontend5 min read

What is the difference between getServerSideProps/getStaticProps and App Router data fetching?

968 views

The problem

Question presented to candidate: "If I know getServerSideProps and getStaticProps, how does data fetching in the App Router map to them, and what actually changes for the user and the payload?"

What a strong answer should cover:

  • Pages Router: getServerSideProps runs per request, getStaticProps at build (with revalidate for ISR), getStaticPaths lists dynamic pages; only the page file can fetch.
  • Their return value is serialized into __NEXT_DATA__ JSON in the HTML, including props the component never renders.
  • App Router: any Server Component can await data; the rendering mode (static, ISR, dynamic) follows from what the code reads and its cache settings.
  • The mapping: getServerSideProps is a dynamic route, getStaticProps is a static route with fetch caching or revalidate, getStaticPaths is generateStaticParams.
  • The client receives the RSC payload (rendered output) instead of the raw props JSON.

Clarifying questions expected:

  • "Is the app migrating incrementally?" β€” both routers can run side by side.
  • "Which pages need per-request data?" β€” they become dynamic routes.

Code / implementation expected: Yes β€” the same page in both routers.

  • nextjs
  • getserversideprops
  • getstaticprops
  • data-fetching

Try it yourself

Sketch your approach before you read the solution. That is what the interview tests.

Stuck? Get a hint.

A short nudge toward the approach. It will not give the answer away.

Solution

The solution is hidden so you can try first

5 min read Β· 8 sections

Read the code

The same page in both routers
// pages/products/[id].tsx  (Pages Router)
export async function getServerSideProps({ params }: { params: { id: string } }) {
  const product = await getProduct(params.id);
  return { props: { product } };            // whole object goes into __NEXT_DATA__
}
export default function Product({ product }: { product: { name: string } }) {
  return <h1>{product.name}</h1>;
}

// app/products/[id]/page.tsx  (App Router)
import { cookies } from "next/headers";
export default async function Product({ params }: { params: Promise<{ id: string }> }) {
  const { id } = await params;
  await cookies();                          // per-request, like getServerSideProps
  const product = await getProduct(id);
  return <h1>{product.name}</h1>;          // only the rendered output is sent
}

Discussion

Other approaches, follow-ups and how it went in real interviews.

Sign in to join the discussion.

No comments yet. Share how you would answer it.

Question 35 of 129 in Next.js

Keep your momentum going.

Mark this question solved to track your progress, then take the next one while it is fresh.

All Next.js questions
Up nextMedium

What makes a route dynamic in the Next.js App Router?

Continue