Skip to the solution
MediumFrontend6 min read

What is Turbopack in Next.js and how does it compare to Webpack?

660 views

The problem

Question presented to candidate: "What is Turbopack, is it production ready, and what should a team with a custom Webpack configuration check before relying on it?"

What a strong answer should cover:

  • Turbopack is an incremental bundler written in Rust, built into Next.js; since Next.js 16 it is the default for both next dev and next build.
  • Its speed comes from incremental computation and caching at the function level, so changes recompute only what depends on them.
  • Webpack is still available with --webpack.
  • A custom webpack() function in next.config is never called by Turbopack, and a plain next build that finds one with no turbopack key stops with an error rather than ignoring it: common needs have built-in support or turbopack.rules for Webpack loaders; Webpack plugins are not supported.
  • Configure it under the turbopack key (for example rules, resolveAlias, root); file-system caching, on by default for dev since 16.1 and for builds since 16.3, speeds up restarts.

Clarifying questions expected:

  • "Does next.config have a webpack function or plugins?" β€” those need a migration or --webpack.
  • "Which loaders are used?" β€” many work through turbopack.rules.

Code / implementation expected: Yes β€” moving a loader to turbopack.rules, and the opt-out flag.

  • nextjs
  • turbopack
  • webpack
  • bundler

Try it yourself

Sketch your approach before you read the solution. That is what the interview tests.

Stuck? Get a hint.

A short nudge toward the approach. It will not give the answer away.

Solution

The solution is hidden so you can try first

6 min read Β· 8 sections

Read the code

Moving an SVG loader from webpack() to turbopack.rules
// next.config.ts (before: only runs with --webpack)
const before = {
  webpack(config: any) {
    config.module.rules.push({ test: /\.svg$/, use: ["@svgr/webpack"] });
    return config;
  },
};

// next.config.ts (after: works with Turbopack, the Next.js 16 default)
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
  turbopack: {
    rules: {
      "*.svg": { loaders: ["@svgr/webpack"], as: "*.js" },
    },
  },
};
export default nextConfig;

// still need Webpack for an unsupported plugin?
//   next build --webpack

Discussion

Other approaches, follow-ups and how it went in real interviews.

Sign in to join the discussion.

No comments yet. Share how you would answer it.

Question 59 of 129 in Next.js

Keep your momentum going.

Mark this question solved to track your progress, then take the next one while it is fresh.

All Next.js questions
Up nextMedium

PPR vs ISR vs SSR β€” how do you pick the rendering strategy in Next 15?

Continue