Next.js 5: Universal Webpack, CSS Imports, Plugins and Zones
Key Points
- Universal webpack for server + client
- Plugin-based CSS & TypeScript support
- Zones to compose multiple Next.js apps
Summary
Next.js 5 (published 2018-02-05) introduces a unified Webpack pipeline for both server and client, a plugin system for opt-in loaders and integrations (CSS, SASS, TypeScript, Preact, etc.), Zones for composing multiple Next.js apps under one domain, and several build/performance improvements (faster builds and better dynamic-import caching). Upgrade by running: npm i next@latest react@latest react-dom@latest
Key Points
- Universal Webpack: the webpack decorator now receives an isServer flag so the same loader/tooling can run for server and client bundles.
- Plugin system: use small composer plugins (e.g. next-css, next-sass, next-typescript, @zeit/next-preact) to enable loaders without modifying internals.
- CSS imports: import .css in pages; install needed loaders as peer deps (css-loader, style-loader, postcss-loader) or use next-css to simplify configuration.
- TypeScript: enable via ts-loader + default babel loader or use the next-typescript plugin to wire it up quickly.
- React altlibs: easily swap runtimes (Preact, inferno, etc.) via plugins and aliasing.
- Production sourcemaps: enable by setting config.devtool = 'source-map' when not in development.
- Zones: compose multiple independently deployed Next.js apps under one domain using path-based routing rules and now alias (or micro-proxy / reverse proxies).
- Performance: ~23.6% faster production builds observed on large apps; dynamic imports now use content-addressable hashes to improve cross-deploy caching.
- Fragments/Document: continued support for customizing top-level Document for advanced server-rendered markup control.
Actionable notes
- To migrate custom webpack configs, adapt your next.config.js webpack(config, {dev, isServer, ...}) decorator to handle isServer.
- Prefer plugins for common loaders; add peer deps when required.
- Test dynamic imports and deployment caching after upgrade to benefit from improved caching behavior.