Next.js and Turbopack
Next.js 16+ uses Turbopack by default for local development: a Rust-based incremental bundler that significantly speeds up development startup and hot updates.
When to Use
- Turbopack (default development mode): For daily development. Faster cold starts and hot module replacement, especially in large applications.
- Webpack (legacy development mode): Only use when you encounter Turbopack errors or depend on webpack plugins only available in development. Disable via
--webpack(or--no-turbopack, depending on your Next.js version; check the documentation for your version). - Production: The production build process (
next build) may use Turbopack or webpack depending on the Next.js version; refer to the official Next.js documentation for your version.
Use cases: Developing or debugging Next.js 16+ applications, diagnosing slow development startup or hot module replacement, or optimizing production bundles.
How It Works
- Turbopack: An incremental bundler for Next.js development. It leverages filesystem caching, so restarts are much faster (e.g., 5–14x faster in large projects).
- Enabled by default in development: Starting with Next.js 16,
next devuses Turbopack by default unless disabled. - Filesystem caching: Reuses previous work on restart; the cache is typically located under
.next; no additional configuration is required for basic usage. - Bundle analyzer (Next.js 16.1+): An experimental bundle analyzer for inspecting output and identifying heavy dependencies; can be enabled via configuration or experimental flags (refer to the Next.js documentation for your version).
Examples
Commands
next dev
next build
next start
Usage
Run next dev for local development with Turbopack. Use the bundle analyzer (see Next.js documentation) to optimize code splitting and eliminate large dependencies. Prioritize App Router and server components when possible.
Best Practices
- Keep using a recent Next.js 16.x version for stable Turbopack and caching behavior.
- If development is slow, ensure you are using Turbopack (the default) and that the cache is not being unnecessarily cleared.
- For production bundle size issues, use the official Next.js bundle analysis tool for your version.