OpenAINext.jsJun 28, 2022, 4:00 PM

Next.js 12.2

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.2 — Middleware stable, Edge runtime, SWC plugins

Key Points

  • Middleware stable for dynamic routing
  • On-Demand ISR stable (revalidate without redeploy)
  • Edge runtime support for API routes & SSR (experimental)

Summary

Next.js 12.2 stabilizes Middleware and On-Demand ISR, introduces experimental Edge runtimes for API Routes and SSR, adds experimental SWC plugins, and improves next/image and React 18 support. This release focuses on lower-latency edge experiences, faster compilation options, and better image handling. Upgrade with npm i next@latest.

Key Points

  • Middleware (stable): improved API for running code before requests complete — supports rewrites, redirects, headers, cookies, and dynamic routing via middleware.ts and config.matcher.
  • On-Demand ISR (stable): use res.revalidate('/path') in an API route to refresh static pages without redeploying; on Vercel revalidation propagates globally in ~300ms.
  • Edge API Routes & Edge SSR (experimental): opt into the Edge Runtime with runtime: 'experimental-edge' for low-latency APIs and streaming SSR; note Node-specific APIs (e.g., fs) are not available.
  • SWC Plugins (experimental): customize compilation with WASM-based plugins via experimental.swcPlugins in next.config.js to transform/minify code during builds.
  • next/image improvements: new next/future/image reduces client JS and uses native lazy loading; remotePatterns enables wildcard remote images; experimental.images.unoptimized allows next export without an image optimizer.
  • Tooling and platform: improved React 18 compatibility (styled-components, emotion, next/head, route announcer), reduced install size, and stabilized standalone output (output: 'standalone') for lean deployments.

Upgrade & Action Items

  • Update: npm i next@latest
  • Read migration docs for the new middleware API, Edge runtime caveats, SWC plugin setup, and next/image changes before upgrading production apps.

Full Translation

Translations

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

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

Next.js 12.2

Next.js 12.2

Next.js 12.2 では、安定版の Middleware と On-Demand ISR、実験的な Edge SSR と API Routes、その他多数の改善が導入されます。

主な変更点:

  • 安定版の Middleware
    • エッジでのリクエスト処理を行う Middleware が安定版として利用可能になりました。
  • On-Demand ISR
    • 必要に応じてページを再生成する On-Demand ISR が導入され、より柔軟なキャッシュ制御が可能になります。
  • 実験的な Edge SSR と API Routes
    • Edge 上でのサーバーサイドレンダリング(Edge SSR)および Edge 対応の API Routes が実験的に利用可能になりました。
  • その他
    • パフォーマンス改善やバグ修正など、多数の小規模な改善が含まれます。

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

Next.js 12.2 | Next.js | DocsDigest