Next.js 9.1: src & public dirs, experimental CSS and performance improvements
Key Points
- src/pages support
- public/ replaces static
- experimental built-in CSS imports
Summary
Next.js 9.1 introduces optional src directory support for organizing application code, a new public directory (root-mounted assets) that replaces the old static convention (deprecated), and multiple experimental performance features: built-in CSS imports, static error pages optimization, module/nomodule modern bundle delivery, and improved bundle splitting. This release is backward compatible; update by installing latest Next/React packages.
Key Points
- src directory support: you can move pages into src/pages instead of the project root to match common repo layouts.
- public directory: files under
public/are served from the site root (e.g.public/robots.txt→/robots.txt).static/is deprecated; usepublic/static/if needed. - Built-in CSS (experimental): global CSS imports from
pages/_app.jsand planned CSS Modules (*.module.css) with dev hot-reload and production optimizations (feature is behind a flag). - Static error pages (experimental): expected errors like 404 are statically exported by default for better CDN caching and lower server load; opt-out available when dynamic behavior is required.
- Module/nomodule (experimental): serve modern ES module bundles to evergreen browsers and legacy ES5 bundles to older browsers to reduce bytes shipped.
- Improved bundle splitting (experimental): new chunking strategy to produce smaller, better-cached client bundles across diverse page sets.
- Upgrade: run
npm i next@latest react@latest react-dom@latestand consult the upgrade guide if coming from pre-9.x.
Practical notes for engineers
- All new features are backward compatible; experimental features are behind flags and are being A/B tested in production by large apps.
- Migrate static assets into
public/to ensure root path mapping; keepstatic/for now but expect deprecation warnings. - Test module/nomodule and improved chunking in staging to measure TTI and caching improvements before rolling to production.