turbopack
Configure Turbopack loader rules, module aliases and resolvable extensions.
turbopack?: { root?: string; rules?: Record<string, Rule | Rule[]>; resolveAlias?: Record<string, string | Record<string, string>>; resolveExtensions?: string[]; debugIds?: boolean; ignoreIssue?: Array<{ path: string | RegExp; title?: string | RegExp; description?: string | RegExp }> }- Added in Next.js v13.0.0
Parameters
| Parameter | Type | Description |
|---|---|---|
$rootoptional | string= detected from the nearest lockfile | Application root directory as an absolute path. Files outside it are not resolved. Detected automatically from a lockfile such as pnpm-lock.yaml, package-lock.json, yarn.lock or bun.lock. |
$rulesoptional | Record<string, Rule | Rule[]>= {} | Maps a glob such as '*.svg' to webpack loaders, an output rename via `as`, a module `type`, and an optional `condition`. Rules are evaluated in order; an array models disjoint conditions. |
$resolveAliasoptional | Record<string, string | Record<string, string>>= {} | Maps an imported specifier to the module loaded in its place. A nested object applies a condition; only 'browser' is currently supported. |
$resolveExtensionsoptional | string[]= Next.js defaults | Extensions tried when resolving an import. This replaces the default list rather than extending it, so include the defaults you still need. |
$debugIdsoptional | boolean= false | Generates debug IDs in JavaScript bundles and source maps, exposed on globalThis._debugIds. Adds a polyfill to the bundle. |
$ignoreIssueoptional | Array<{ path: string | RegExp; title?: string | RegExp; description?: string | RegExp }>= [] | Suppresses matching Turbopack errors and warnings from the CLI output and error overlay. path is required and is a glob when a string; an issue is suppressed only when it matches path and every other field given. |
Errors
next build fails when a custom webpack config is present, because Turbopack is the default bundler from Next.js 16 — build with --turbopack to ignore it, or --webpack to opt out.
Changelog
- PHP v16.2.0turbopackLoader import attributes, turbopack.rules.*.type, and the condition.contentType and condition.query matchers were added; turbopack.ignoreIssue introduced.
- PHP v16.0.0turbopack.debugIds and turbopack.rules.*.condition were added; Turbopack became the default bundler for next dev and next build.
- PHP v15.3.0experimental.turbo renamed to the top-level turbopack option.
- PHP v13.0.0experimental.turbo introduced.
Turbopack is the default bundler for next dev and next build from Next.js 16. It needs no loader configuration for built-in behavior — CSS, Sass and modern JavaScript work out of the box, so css-loader, postcss-loader and babel-loader with @babel/preset-env have nothing to do.
When to reach for it
rulesfor a transform Turbopack does not have, most often@svgr/webpackto import SVGs as components. Only loaders that return JavaScript are supported.resolveAliasto redirect a specifier: aliasingfsto an empty module for the browser, or mapping Sass's legacy~prefix.rootwhen your monorepo has no lockfile where Turbopack expects one, or when you develop against anpm linked package outside the project.ignoreIssueto silence a known warning, such as an optional dependency inside atry/catch require().
What trips people up
resolveExtensions overwrites the default list — omit .tsx or .js and resolution breaks everywhere. Rule globs match the file name unless the pattern contains /, in which case they match the project-relative path. And a leftover webpack config fails next build outright, including one a plugin added on your behalf.
Example
import type { NextConfig } from 'next'
const nextConfig: NextConfig = {
turbopack: {
rules: {
'*.svg': {
loaders: ['@svgr/webpack'],
as: '*.js',
},
},
},
}
export default nextConfigWhen to use it
- Import SVG files as React components through @svgr/webpack.
- Point a browser-side import of a Node built-in at an empty module to clear a Module not found error.
- Set the project root so a monorepo or an npm-linked package outside the app resolves.
- Hide a known Turbopack warning from an optional dependency without hiding real errors.
Frequently asked questions
Why does next build fail because a webpack configuration was found?
Turbopack is the default for next build from Next.js 16, and a custom webpack config would be silently ignored, so the build fails instead. Run next build --turbopack to ignore the webpack config, next build --webpack to opt out of Turbopack, or migrate the config to turbopack options — and check your plugins, since one of them may be adding the webpack key.
How do I use SVGR with Turbopack?
Add a rule mapping '*.svg' to the @svgr/webpack loader with as: '*.js' under turbopack.rules. Loader options must be plain JSON values, and only loaders that return JavaScript are supported.
What replaced experimental.turbo in next.config?
The top-level turbopack option, renamed in v15.3.0. The old key still works as an alias, and npx @next/codemod@latest next-experimental-turbo-to-turbopack . migrates the config for you.
More examples
Silencing a Node module error in browser code
This is the Turbopack equivalent of webpack's resolve.fallback, for Module not found: Can't resolve 'fs' coming from client code. The browser condition scopes the alias to browser targets. It silences the error rather than fixing it — refactoring so client bundles never reach a Node built-in is the better outcome.
import type { NextConfig } from 'next'
const nextConfig: NextConfig = {
turbopack: {
resolveAlias: {
fs: {
browser: './empty.ts', // prefer fixing the import instead
},
'~*': '*', // legacy Sass tilde imports
},
},
}
export default nextConfigRestricting a loader with a condition
'foreign' matches node_modules and Next.js internals, so { not: 'foreign' } keeps the loader off dependency SVGs — fewer files to run it on, and no interference with a package that ships its own handling. Loader options must be plain JSON-compatible values; a required() plugin instance cannot be passed.
import type { NextConfig } from 'next'
const nextConfig: NextConfig = {
turbopack: {
rules: {
'*.svg': {
condition: { not: 'foreign' },
loaders: [
{
loader: '@svgr/webpack',
options: { icon: true },
},
],
as: '*.js',
},
},
},
}
export default nextConfigSuppressing a known optional-dependency warning
An optional require() inside a try/catch produces a Module not found warning that never affects runtime. The rule suppresses it in both the CLI and the error overlay. Keep path as narrow as possible: issue titles and descriptions can change between Turbopack versions, so matching on them is more brittle than matching on the file path.
import type { NextConfig } from 'next'
const nextConfig: NextConfig = {
turbopack: {
ignoreIssue: [
{
path: '**/lib/optional-feature/**',
title: 'Module not found',
},
],
},
}
export default nextConfig
Discussion