skip to content

In a Next.js project, what is Turbopack, and what does running `next dev --turbopack` do differently from running the dev server on webpack?

level: juniorimportance: should knowfreq 58%

answer

  1. Rust bundler shipped inside Next
  2. replaces webpack, not React
  3. compiles routes on demand in dev
  4. default from Next 16, --webpack opts out

basics

~20 s

Turbopack is Next.js's Rust-based bundler, built to replace webpack for both the dev server and production builds. next dev --turbopack starts the dev server on Turbopack; in Next 16 Turbopack is the default for dev and build, and --webpack opts back out.

solid answer

~50 s

Turbopack is the bundler Next.js uses to resolve imports, run transforms and emit the JavaScript and CSS that the browser and the server actually load — the job webpack used to do. It is written in Rust and built around an incremental engine that caches compilation work at a fine granularity, and in development it compiles **on demand**: it builds the route you request rather than the whole app up front, which is why cold start and edit-to-refresh feel much faster on a large codebase. `next dev --turbopack` selects it for the dev server. Turbopack went stable for `next dev` in the Next 15 line and for `next build` later in that line, and in Next 16 it is the default for both, so the flag is redundant there and `--webpack` is the escape hatch. Swapping bundlers changes nothing about the App Router, Server Components or caching — but a custom `webpack()` config in `next.config` is not honoured by Turbopack.

go deeper

for a junior

Be able to say in one breath that Turbopack is Next.js's Rust bundler replacing webpack, that next dev --turbopack runs the dev server on it, and that it is about build speed, not about how your components work.

for a middle

Explain the mechanics that make it faster — on-demand compilation in dev plus fine-grained caching — and know that transforms still run through SWC and that CSS, CSS Modules, PostCSS and Sass are handled natively.

for a senior

An interviewer expects you to name the practical migration risk: custom webpack configuration and plugins do not carry over, so you audit next.config and the toolchain before flipping a real project.

for a principal

Own the framing that bundler choice is a developer-productivity and supply-chain decision: what the faster feedback loop is worth across a team, what a divergent pipeline costs, and how you avoid stranding the codebase on the legacy path.

## What a bundler does, and what Turbopack replaces A bundler is the tool that walks your import graph, applies transforms (TypeScript to JavaScript, JSX, CSS Modules, images), and emits the artifacts that actually run — the client chunks the browser downloads and the server code Next executes. Next.js did that with **webpack** for most of its life. Turbopack is the replacement, written in Rust by the Next.js team and shipped inside the `next` package: you do not install or configure it as a separate dependency. A common mix-up worth clearing early: **Turbopack is not Turborepo**. Turborepo is a monorepo task runner that caches and schedules `build`/`test`/`lint` commands across packages. Turbopack is the bundler inside one Next.js app. They share branding and nothing else. ## What the flag does ```bash next dev --turbopack # dev server on Turbopack next dev --webpack # dev server on webpack (Next 16 opt-out) next build --turbopack # production build on Turbopack ``` Running the dev server on Turbopack changes three things you can see immediately. Startup no longer compiles the whole application — the server comes up and compiles a route when you first request it. Edits are applied through a fast incremental update rather than a re-bundle of the affected chunk graph. And the terminal output is Turbopack's, so the familiar webpack compile lines are gone. In Next 16 Turbopack is the default bundler for both `next dev` and `next build`, so the `--turbopack` flag is a no-op there and `--webpack` is what you pass to go back. On earlier Next 15 releases the flag was how you opted in — dev first, builds later in the line. ## Why a second bundler at all webpack is JavaScript, so its work happens largely on one thread inside Node, and its caching is coarse-grained: a change tends to invalidate a whole module's downstream work. On applications with thousands of modules that produced dev servers taking tens of seconds to start and seconds to reflect a keystroke. Turbopack attacks both. Rust gives native execution speed and real parallelism across cores. Its engine caches individual units of compilation work keyed by their inputs, so after an edit it recomputes only the units whose inputs actually changed. And in development it is demand-driven — it never pays for routes you did not open. ## What does not change Switching bundlers is not a framework change. File conventions (`page`, `layout`, `loading`, `route`), Server Components, Server Actions, the caching layers and rendering modes behave identically. Code transforms still go through SWC, the same Rust compiler the webpack path already used via `next-swc`, so your TypeScript and JSX are handled the same way. Turbopack has built-in handling for CSS, CSS Modules, PostCSS (it reads a `postcss.config` file) and Sass when the `sass` package is installed. ## Where it bites The rough edge is customization. A `webpack(config)` function in `next.config` is only consulted by webpack — Turbopack ignores it, and Next warns rather than silently doing what you meant. Turbopack has its own `turbopack` config key with `rules` (a subset of webpack loaders), `resolveAlias` and `resolveExtensions`. There is **no webpack plugin API**, so anything shipped as a plugin needs a Turbopack-native equivalent or a different place in the pipeline. Turbopack also does not automatically switch to Babel when it finds a Babel config the way the webpack path did. For a plain App Router app with no custom bundler configuration — which is most new projects — none of that applies and the switch is invisible apart from the speed.

  • Does moving to Turbopack change anything about how Server Components or the App Router behave?
    No. Turbopack is a bundler swap: it changes how your code is compiled and served, not the framework semantics on top of it. File conventions, Server Components, Server Actions, rendering modes and the caching layers behave the same. What can change is anything that depended on bundler customization — a custom `webpack()` function, a webpack plugin, or a loader Turbopack does not support.
  • Turbopack and Turborepo are frequently confused. What is the difference?
    Turbopack is a bundler: it compiles and bundles the modules of a single Next.js application, and it ships inside the `next` package. Turborepo is a monorepo task runner: it schedules and caches commands like build, test and lint across the packages of a workspace, and is installed separately. They are different tools that solve different problems and share only a name prefix.
  • If Turbopack is the default, why would a team still pass --webpack?
    Because their build depends on bundler customization Turbopack cannot express yet — most often a webpack plugin, since Turbopack has no plugin API, or a loader that relies on webpack-specific internals. `--webpack` keeps them shipping while they port or replace that piece. It is a temporary lever, not a destination: webpack is the legacy path in Next 16 and the defaults will keep moving away from it.

saying these in an interview costs you the question

  • Says Turbopack replaces React or replaces Next.js itself
  • Thinks Turbopack is dev-only and cannot produce production builds
  • Confuses Turbopack with Turborepo, the monorepo task runner
  • Assumes an existing webpack() config keeps applying under Turbopack
  • Claims Turbopack is a separate package you install alongside next

context