Next.js Developer interview question · Most asked

How do `getServerSideProps`, `getStaticProps` and `getStaticPaths` work in the Pages Router?

Summary

getServerSideProps runs on every request and passes props to the page (SSR); getStaticProps runs at build time (with optional revalidate for ISR); getStaticPaths lists dynamic paths to pre-render, with fallback controlling unknown paths.

Longer Answer

fallback: false 404s unknown paths, true serves a fallback UI then renders, and 'blocking' renders on first request like SSR, then caches. These functions only run on the server, so they can access secrets. In the App Router, async Server Components replace them.

Key Points

  • getServerSideProps: per request
  • getStaticProps + revalidate: SSG/ISR
  • getStaticPaths + fallback modes
  • Replaced by async Server Components in App Router

More most-asked Next.js Developer questions

← All Next.js Developer questions