Next.js uses a Rust-based compiler architecture built on SWC, now featuring Turbopack as the default bundler since version 16, delivering significantly faster builds and Fast Refresh compared to the legacy Webpack/Babel setup.
Next.js has undergone a significant evolution in its compiler architecture, transitioning from JavaScript-based tools (Babel and Terser) to a Rust-powered stack. The foundation of this new architecture is SWC (Speedy Web Compiler) . Since version 12, Next.js has used SWC to replace Babel for transpilation and Terser for minification . This shift was the first major step toward faster build times, with Next.js reporting up to 17x faster compilation than the previous Babel setup.
1. SWC: The Foundation
SWC (Speedy Web Compiler) is an extensible Rust-based platform used for compilation, minification, and bundling . It is designed to be a low-level, embeddable engine that higher-level tools like Next.js can call to perform code transformations. SWC's performance advantages come from being written in Rust (compiled to native code) and its ability to aggressively parallelize work across multiple CPU cores. Benchmarks show SWC can be 20x faster than Babel on a single thread and up to 70x faster on four cores . Next.js uses SWC for core tasks including: transpiling JavaScript and TypeScript, handling JSX/TSX compilation, and minifying production bundles (7x faster than Terser) .
2. Turbopack: The Default Bundler (Next.js 16+)
Building on SWC, Next.js introduced Turbopack, a Rust-based incremental bundler designed specifically for the framework . Starting with Next.js 16, Turbopack became the default bundler for both development and production builds . Unlike Webpack, Turbopack uses a unified graph for all environments (client, server), bundles only what the dev server actually requests (lazy bundling), and caches results down to the function level for incremental computation .
Next.js 16 also provides stable built-in support for the React Compiler, which automatically memoizes components to reduce unnecessary re-renders without manual useMemo or useCallback . The compiler is not enabled by default, as it can increase build times. You can enable it in your Next.js configuration. Note that enabling this option will increase compile times in development and during builds, as the React Compiler relies on Babel .
4. Supported Features and Configuration
JavaScript & TypeScript (using SWC)
ECMAScript (ESNext) features
CommonJS and ESM modules
JSX / TSX compilation
Fast Refresh for instant feedback
React Server Components (RSC)
Global CSS and CSS Modules (via Lightning CSS)
CSS Nesting and @import
PostCSS (processes config files in Node.js worker pool)
Sass / SCSS support
styled-components: Built-in support via compiler.styledComponents config
Emotion: Built-in support via compiler.emotion config
Remove Console: compiler.removeConsole to strip console.* calls in production
Remove React Properties: compiler.reactRemoveProperties to strip test attributes
Relay: compiler.relay for GraphQL compilation
Jest integration: next/jest automatically configures SWC transforms
Webpack plugins are not supported; you must find Turbopack-compatible alternatives or continue using Webpack with the --webpack flag
Custom Sass functions (sassOptions.functions) are not supported because Turbopack's Rust architecture cannot execute JavaScript functions
Less is not yet supported by default (planned via plugins)
Some legacy CSS Modules features are not supported (e.g., :local/:global as standalone pseudo-classes, :import/:export ICSS rules)
Yarn PnP is not planned for Turbopack support
AMP support is not planned for Turbopack
Starting in Next.js 16, Turbopack automatically uses Babel if it detects a configuration file
Unlike Webpack, SWC is always used for Next.js's internal transforms even when Babel is present
Files in node_modules are excluded from Babel processing unless manually configured with babel-loader
If your application depends on features not yet supported by Turbopack (such as specific Webpack plugins or custom Sass functions), you can continue using Webpack by adding the --webpack flag to your dev and build scripts . This is also necessary for platforms without native Turbopack bindings, where Next.js falls back to WebAssembly (WASM) bindings that support core SWC features but not Turbopack .