description: Enable the React Compiler to automatically optimize component rendering.
version: experimental
---
Next.js includes support for the [React Compiler](https://react.dev/learn/react-compiler), a tool designed to improve performance by automatically optimizing component rendering. This reduces the need for manual memoization using `useMemo` and `useCallback`.
Next.js includes support for the [React Compiler](https://react.dev/learn/react-compiler/introduction), a tool designed to improve performance by automatically optimizing component rendering. This reduces the need for manual memoization using `useMemo` and `useCallback`.
Next.js includes a custom performance optimization written in SWC that makes the React Compiler more efficient. Instead of running the compiler on every file, Next.js analyzes your project and only applies the React Compiler to relevant files. This avoids unnecessary work and leads to faster builds compared to using the Babel plugin on its own.
...
...
@@ -20,15 +19,13 @@ To use it, install the `babel-plugin-react-compiler`:
npm install babel-plugin-react-compiler
```
Then, add `experimental.reactCompiler` option in `next.config.js`:
Then, add `reactCompiler` option in `next.config.js`:
```ts filename="next.config.ts" switcher
import type { NextConfig } from 'next'
const nextConfig: NextConfig = {
experimental: {
reactCompiler: true,
},
reactCompiler: true,
}
export default nextConfig
...
...
@@ -37,9 +34,7 @@ export default nextConfig
```js filename="next.config.js" switcher
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
reactCompiler: true,
},
reactCompiler: true,
}
module.exports = nextConfig
...
...
@@ -53,10 +48,8 @@ You can configure the compiler to run in "opt-in" mode as follows: