- Runs at build time only, meaning if there’s no
getInitialProps
, the page will be served as a static file (no SSR). - Can pass data to the page component as props.
- In development runs on every request
- Runs at build time only.
- Configures pre-building variants of dynamic routes (e.g.
pages/blog/[post].js
), can define variants to pre-build and still have other variants built on-demand (the first time it is requested). - Turns out requests to explicit page routes take precedence over dynamic routes, so it’s possible to model complex routing schemes with
pages
.
- Runs on every request (always SSR).
- Can pass data to the page component as props.
- Can not be used alongside
getStaticProps
.
- Next.js Preview Mode
- Can be used to make static pages act as if they were SSR’ed, meaning their getStaticProps and getStaticPaths will run on every request.
- Useful for previewing CMS content changes immediately without waiting for the cache to refresh.
When working with CMS content that changes, there’s 2 options to make it work with
getStaticProps
:Additional resources for implementing Serverless Pre-Rendering:
Successor: