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.