OpenAINext.jsFeb 17, 2022, 4:00 PM

Next.js 12.1

A condensed section focused on the key takeaways first.

Original Post

Quick Digest

Summary

A condensed section focused on the key takeaways first.

openaienmodel: gpt-5-mini-2025-08-07

Next.js 12.1 — On-demand ISR, expanded SWC, next/jest, and self-hosting improvements

Key Points

  • On-demand ISR (Beta) for instant page revalidation
  • Expanded SWC transforms + RC minifier (7x faster)
  • next/jest: zero-config Jest using SWC

Summary

Next.js 12.1 (2022-02-17) introduces on-demand Incremental Static Regeneration (Beta), expanded SWC transforms and SWC-based minification (RC), a zero-configuration Jest plugin (next/jest), faster image optimization (stale-while-revalidate), and self-hosting improvements that produce much smaller Docker images. It also includes early React 18 / Server Components support (Alpha) and other developer ergonomics and performance improvements. Update with npm i next@latest.

Key Points

  • On-demand ISR (Beta)

    • New API: call res.unstable_revalidate('/path-to-revalidate') from an API route to purge and re-generate a specific getStaticProps page on-demand.
    • Example pattern: protect the revalidation endpoint with a secret token, call unstable_revalidate(); getStaticProps does not need revalidate set to use on-demand.
    • On Vercel, on-demand revalidation propagates globally in ~300ms.
  • Expanded SWC support and faster minification (RC)

    • SWC transforms added: styled-components, importSource, legacy-decorators, relay, remove-react-properties, remove-console.
    • SWC minifier is Release Candidate and reported ~7x faster than Terser. Opt in via module.exports = { swcMinify: true }.
  • Zero-configuration Jest (next/jest)

    • Automatically configures Jest using the Next.js compiler (SWC): auto-mocks styles/images, loads .env, ignores .next and node_modules transforms, and respects next.config.js flags.
  • Self-hosting / Docker

    • Enable experimental.outputStandalone: true in next.config.js to produce .next/standalone for smaller production bundles (~80% smaller Docker images) and deploy without node_modules.
  • Image optimization

    • Image cache now supports stale-while-revalidate (serve stale image and revalidate in background) for better performance.
  • React 18, Server Components, and Edge runtime (Alpha)

    • Improvements for Server Components, SSR streaming, useId support, partial hydration and ability to choose Node.js or Edge runtime per page (experimental).
  • Additional practical notes

    • Many developer-experience fixes: Fast Refresh speedups, ESLint 8 support, styled-jsx 5.0, various accessibility and routing bug fixes.

Actionable items for engineers

  • Upgrade: npm i next@latest.
  • To use on-demand ISR: implement a secure API route that calls res.unstable_revalidate('/path').
  • To try faster minification: set swcMinify: true in next.config.js.
  • To reduce self-hosted image size: set experimental.outputStandalone: true and use .next/standalone in your Docker image.
  • Evaluate next/jest to simplify Jest setup and get SWC-based transforms.

Full Translation

Translations

A translation section that keeps the flow of the original article.

openaijamodel: gpt-5-mini-2025-08-07

Next.js 12.1

Next.js 12.1 — 新機能

Next.js 12.1 は on-demand ISR、styled-components と Relay のサポート、ゼロコンフィグの Jest サポートなどを導入します。

主な変更点

  • on-demand ISR(オンデマンド ISR): 必要に応じて静的ページを再生成できる on-demand ISR を導入。
  • styled-components と Relay のサポート: styled-components と Relay の公式サポートが追加されました。
  • ゼロコンフィグの Jest サポート: Jest が追加の設定なしで使えるようになりました(zero-config)。
  • その他: パフォーマンス改善やバグ修正など多数の改善が含まれています。

詳しくは公式リリースノートを参照してください。

Next.js 12.1 | Next.js | DocsDigest