Next.js 5.1 — Faster Page Resolution, Runtime Config, Source Maps & Plugins
Key Points
- 102x faster page resolution
- publicRuntimeConfig & serverRuntimeConfig
- Production source maps via plugin
Summary
Next.js 5.1 focuses on performance and developer experience: page resolution is ~102x faster, runtime configuration is available for server/client, error handling and reloads were improved, production source maps are supported, and new/improved plugins are included. The release also adds phase-aware next.config.js exports to load plugins only when needed.
Key Points
- Upgrade: npm i next@latest react@latest react-dom@latest. Also update any next-plugins (e.g. @zeit/next-css, @zeit/next-sass, @zeit/next-less, @zeit/next-typescript).
- Page resolution: resolver rework reduced average page-resolve time from ~2.347ms to ~0.023ms (~102x speedup).
- Runtime config: define serverRuntimeConfig and publicRuntimeConfig in next.config.js and read via getConfig() from next/config (server-only vs server+client values).
- Error handling: router now detects 404 page-bundle responses and auto-reloads; Router.onAppUpdated was removed. Added integration tests for dev error recovery.
- Phases/config: next.config.js can export a function (phase, {defaultConfig}) => config; use next/constants (e.g. PHASE_DEVELOPMENT_SERVER) to conditionally load plugins.
- Source maps: enable production source maps manually via webpack devtool/UglifyJsPlugin or use @zeit/next-source-maps. app.js was replaced by main.js so source maps can be generated correctly.
- Plugins: new @zeit/next-bundle-analyzer; improvements to css/less/sass plugins (hot-reload fixes, no flash of unstyled content, subcomponent styles picked up).
Migration notes
- Update peer dependencies and all next-plugins to compatible versions.
- Remove reliance on Router.onAppUpdated; rely on automatic reload behavior for page-bundle mismatches.
- If you need production source maps, enable them via @zeit/next-source-maps or the webpack config snippet in next.config.js.