Next.js 9.3 — SSG & SSR APIs, Preview Mode, and Sass
Key Points
- getStaticProps/getServerSideProps added
- Preview Mode for CMS drafts
- Built-in Sass and smaller runtime
Summary
Next.js 9.3 introduces first-class SSG and SSR data-fetching APIs (getStaticProps, getStaticPaths, getServerSideProps), Preview Mode for showing CMS drafts, built-in Sass support (global and CSS modules), automatic static 404 optimization, and a ~32KB smaller runtime. All changes are backwards compatible and can be adopted incrementally.
Upgrade: run npm i next@latest react@latest react-dom@latest.
Key Points
-
New data-fetching APIs
getStaticProps: fetch at build time (server-only; tree-shaken from client bundles). Use for CMS-driven or publicly cacheable pages that should be pre-rendered.getStaticPaths: provide dynamic route paths to pre-render at build time; returnfallback: false(unknown paths 404) orfallback: true(on-demand static generation with a loading state).getServerSideProps: fetch on every request (SSR); runs server-side and is tree-shaken from the client.
-
Preview Mode
- Lets you bypass static output to render draft content from a CMS for previewing without changing the published static files.
-
Styling & runtime
- Built-in Sass support: import
.scssfor global styles and.module.scssfor locally scoped CSS modules. - 404 now automatically served statically for faster, more reliable responses.
- Runtime reduced by ~32KB for better baseline performance.
- Built-in Sass support: import
-
Other
- Discussions moved to GitHub Discussions for community Q&A.
- No breaking changes;
getInitialPropsremains supported but new APIs are recommended for new pages.