The React Compiler: Automatic Memoization Explained
The React Compiler 1.0 memoizes components for you, so most useMemo and useCallback calls become unnecessary. How it works and how to enable it in Next.js.
By UndieGravity, , 1 min read
For years, keeping React apps fast meant wrapping values in useMemo, functions in useCallback, and components in memo, and getting the dependency arrays exactly right. The React Compiler does this work at build time. It reached its stable 1.0 release in 2025, and Next.js 16 supports it with one config option.
What it does
The compiler reads your components and hooks during the build and inserts memoization where it is safe. When a parent re-renders, children whose inputs did not change are skipped automatically, and expensive values are recalculated only when their inputs change.
Enable it in Next.js 16
npm install -D babel-plugin-react-compiler// next.config.ts
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
reactCompiler: true,
};
export default nextConfig;The option is stable but off by default. Because the compiler runs through Babel, expect development and build times to increase somewhat. Measure on your project before deciding.
It relies on the Rules of React
The compiler assumes your code follows React's rules. When a component breaks them, the compiler skips that component rather than produce wrong output. The rules that matter most:
- Components and hooks are pure: same props and state give the same output.
- Do not mutate props, state, or values after they are rendered.
- Call hooks only at the top level, never in loops or conditions.
The eslint-plugin-react-hooks rules report code the compiler cannot optimize. Fix those warnings first; they are usually real bugs anyway.
Should you delete useMemo and useCallback?
In new code, write without them and let the compiler handle it. In existing code there is no rush: the compiler works alongside manual memoization. Remove manual calls gradually, testing as you go, especially where a memoized value is used as an effect dependency.
Where it will not help
- Slow network requests or large data downloads.
- Rendering thousands of rows at once; use list virtualization.
- Heavy work in the browser; move it to the server or a Web Worker.