OpenAINext.jsOct 26, 2021, 4:00 PM

Next.js 12

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 — Major release: Rust compiler, Middleware, React 18 support

Key Points

  • rust-based compiler: much faster builds
  • edge middleware (beta) for request-time code
  • experimental React 18 & server components support

Summary

Next.js 12 is a major release focused on build/runtime speed, edge-first middleware, and early support for React 18 features. It introduces a Rust-based compiler (SWC) for much faster builds and refresh, edge-capable Middleware (beta), experimental React 18 and Server Components support, URL imports/ESM improvements, AVIF image support, and output file tracing for standalone deployments.

Upgrade quickly: npm i next@latest.

Key Points

  • Rust compiler (SWC): ~3x faster Fast Refresh and ~5x faster production builds; swcMinify: true enables faster minification. Backwards-compatible with custom Babel configs.
  • Middleware (beta): run code before a request completes (rewrite, redirect, headers, streaming). Create pages/_middleware.js and use standard Web APIs (Response, fetch). Works on Edge.
  • React 18 & Server Components (experimental): enable with experimental.concurrentFeatures: true and serverComponents: true to try SSR streaming, Suspense and component-level data fetching.
  • ES Modules & URL Imports (experimental): ESM is default; import modules from URLs by allowing prefixes in next.config.js (experimental.urlImports). Next.js generates next.lock and caches remote modules.
  • AVIF images: opt-in via images.formats = ['image/avif','image/webp'] for ~20% smaller images when supported.
  • Bot-aware ISR fallback: crawlers auto-render ISR pages (fallback: true) to avoid indexing loading states.
  • Output file tracing: Next.js uses @vercel/nft to trace and emit required files per page/route to simplify deployments and enable smaller standalone outputs.
  • Misc: support for next.config.mjs, custom tsconfig.json path, improved Fast Refresh telemetry, single-file next lint --file.

Breaking Changes & Notes

  • Webpack 4 removed; webpack 5 is required. Test plugins/loaders for webpack 5 compatibility.
  • Many features are experimental; enable explicitly and test before production use.

Practical Action Items

  • Run npm i next@latest, test local dev and production builds.
  • If using custom Babel, verify behavior; opt into SWC minifier with swcMinify: true when ready.
  • Audit middleware, react-18 flags, and any webpack plugins for compatibility before upgrade.

Full Translation

Translations

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

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

Next.js 12 の新機能

概要

Next.js 12 は多数の新機能と改善を導入しています。以下が主な変更点です。

  • 新しい Rust 製コンパイラ
    • ビルド速度と最適化の向上を目的とした新しい Rust ベースのコンパイラを導入。
  • Middleware (beta)
    • リクエスト段階でエッジ上に軽量なコードを挿入できる Middleware 機能(ベータ)。
  • React 18 Support
    • React 18 の互換性と新機能のサポート。
  • Native ESM Support
    • ネイティブ ESM のサポートにより、モジュールの扱いと互換性が改善。
  • URL Imports
    • 直接 URL からモジュールをインポートする機能。
  • React Server Components (alpha)
    • React Server Components の実験的サポート(アルファ)。

その他にも多数の改善と新機能が含まれています。

Next.js 12 | Next.js | DocsDigest