updated
React Compiler 1.0: Automatic Memoization and useMemo
React Compiler is stable since 1.0 (October 2025), but React 19 does not memoize on its own. What the compiler does, when useMemo stays, and "use memo".

The short answer
- Is React Compiler stable? Yes. React Compiler 1.0 shipped as the first stable release on October 7, 2025, and 1.0.0 is still the current version. It's the project React used to call React Forget.
- Does React 19 memoize automatically? Not by itself. The compiler is a separate build step, a Babel plugin you turn on in your bundler or framework. It isn't React 19 only, either: it supports React 17 and 18 through the
targetoption and thereact-compiler-runtimepackage. - Do you still need
useMemoanduseCallback? Rarely in new code. React's docs keep them as an escape hatch, for example when a memoized value is an effect dependency. In existing code, leave them in place or test before you remove them, because removing them can change what the compiler outputs. - Directives.
"use no memo"at the top of a function skips it, whatever the mode."use memo"opts a function in, which mainly matters undercompilationMode: 'annotation', where only marked functions are compiled. The default mode,'infer', compiles functions named like components or hooks that create JSX or call hooks.
For years, writing performant React meant wrapping things in useMemo, stabilizing callbacks with useCallback, and reaching for React.memo whenever a list item felt slow. The mental overhead was real - dependency arrays, stale closures, and the constant question: "did I memoize this correctly?"
React Compiler v1.0, released in October 2025, changes that calculus. It is a build-time tool that analyzes your components and inserts memoization automatically. In most cases, you write plain code and the compiler handles the rest.
The compiler writes the memoization for you at build time
The React Compiler is a Babel plugin that transforms your source code before it reaches the browser (Next.js still uses the Babel plugin, but an SWC pass picks only the files with JSX or hooks to run it on). It reads each component, builds a dependency graph of every value and function, and generates optimized output - similar to what you would write manually with useMemo and useCallback, but more precise.
Take a simple example:
// What you write
function Dashboard({ data }) {
const summary = computeExpensiveSummary(data);
return <SummaryCard data={summary} />;
}The compiler transforms this roughly into:
// What the compiler generates
function Dashboard({ data }) {
const summary = useMemo(() => computeExpensiveSummary(data), [data]);
return <SummaryCard data={summary} />;
}But it goes further than what most developers write manually. Functions passed as props get stable references automatically. Child components are treated as effectively memoized when their inputs do not change. The compiler applies memoization at the granularity of individual expressions, not just at the hook call level.
The key requirement: your components must be pure. The compiler assumes that render functions have no side effects and that the same inputs always produce the same output. If your component mutates external state during render, the compiler either skips it or produces incorrect output.
Enabling it in Next.js and Vite
The compiler is opt-in everywhere, including Next.js: create-next-app asks about it, and its recommended defaults leave it off. Start by installing the Babel plugin (installation guide):
npm install -D babel-plugin-react-compilerFor Vite with @vitejs/plugin-react 6 or later:
// vite.config.ts
import { defineConfig } from 'vite';
import react, { reactCompilerPreset } from '@vitejs/plugin-react';
import babel from '@rolldown/plugin-babel'; // npm install -D @rolldown/plugin-babel
export default defineConfig({
plugins: [
react(),
babel({ presets: [reactCompilerPreset()] }),
],
});Version 6 removed the inline babel option. On older versions of the plugin, pass babel: { plugins: ['babel-plugin-react-compiler'] } to react() instead.
For Next.js 16 (docs):
// next.config.ts
const nextConfig = {
reactCompiler: true,
};
export default nextConfig;In Next.js 15 the same option lived under experimental.reactCompiler; Next.js 16 made it stable and moved it to the top level.
Once enabled, open React DevTools. Components optimized by the compiler show a Memo ✨ badge. If a component is not optimized, the compiler skipped it - usually because it detected a purity violation.
Check what the compiler did, don't assume
The compiler's lint rules flag code it cannot safely optimize. They now ship in eslint-plugin-react-hooks, so the separate eslint-plugin-react-compiler is no longer needed (React's announcement). The linter doesn't require the compiler to be installed, so you can turn it on first:
npm install -D eslint-plugin-react-hooks@latest// eslint.config.js
import reactHooks from 'eslint-plugin-react-hooks';
export default [
reactHooks.configs.flat.recommended,
];Treat compiler lint errors as blockers, not warnings. They surface exactly the patterns that prevent optimization.
Four cases where you still need useMemo and useCallback
The compiler handles the vast majority of cases, but not all of them. There are four categories where you still have to think about memoization yourself.
Third-party libraries with interior mutability
Some libraries expose functions whose reference stays the same but whose return value changes internally. react-hook-form's watch function is a known example, and React's linter flags it as an incompatible library. Memoizing it doesn't help - the memoized value would simply never update. Use the subscription hook the library provides instead, here useWatch:
// ❌ The compiler can't see that watch() changes - the value goes stale
const { watch } = useForm();
const values = watch();
// ✅ useWatch subscribes to changes properly
const { control } = useForm();
const values = useWatch({ control });Drag-and-drop libraries like react-dnd also depend on reference equality for registering handlers. Removing memoization there causes handlers to re-register on every render.
Libraries that compare props by identity
Chart libraries, map libraries, and some animation libraries accept callbacks or config objects and compare them by reference to decide whether to re-render. If you pass an unstabilized function to these, the library will re-render on every React render regardless of what the compiler does:
// Chart.js and similar libs compare this by identity
const chartOptions = useMemo(() => ({
scales: { y: { beginAtZero: true } },
onClick: handleBarClick,
}), [handleBarClick]);Genuinely expensive computations you want to control explicitly
For calculations that are measurably slow - filtering tens of thousands of items, running complex transforms - keeping an explicit useMemo documents intent and gives you precise control over when recomputation happens:
// Intentional - expensive and worth documenting
const sortedAndFilteredRows = useMemo(() =>
rows
.filter(row => matchesAllFilters(row, activeFilters))
.sort(comparator),
[rows, activeFilters, comparator]
);Values an effect depends on
React's own docs name this one: a memoized value used as an effect dependency. The compiler will usually memoize it anyway, but an explicit useMemo states the guarantee the effect relies on, so the effect doesn't re-run when nothing meaningful changed:
// The connection should restart only when the room or server really changes
const options = useMemo(() => ({ roomId, serverUrl }), [roomId, serverUrl]);
useEffect(() => {
const connection = createConnection(options);
connection.connect();
return () => connection.disconnect();
}, [options]);The rule of thumb: if you are adding useMemo defensively - "just in case" - remove it and let the compiler handle it. If you are adding it because you measured a real cost or because a third-party library requires it, keep it.
"use no memo" opts a component out
If the compiler optimizes a component incorrectly - which can happen with complex state patterns it cannot statically analyze - you can opt out with the 'use no memo' directive:
function ComplexComponent({ data }) {
'use no memo';
// compiler skips this component entirely
// ...
}Use this sparingly. React's docs describe it as a temporary debugging tool, not a general escape from fixing purity violations - leave a comment explaining why it's there. It also works at the top of a file to skip every function in it, and it wins over any compilationMode and over "use memo".
The opposite directive, 'use memo', is for opting in. You only need it with compilationMode: 'annotation', where the compiler touches nothing you haven't marked. That's a useful way to roll it out one component at a time (Next.js docs):
// next.config.ts
const nextConfig = {
reactCompiler: { compilationMode: 'annotation' },
};
export default nextConfig;function Dashboard({ data }) {
'use memo';
// only functions marked like this get compiled
}Migrate incrementally, not in one big PR
Do not try to migrate everything at once. The compiler is additive - it works alongside existing memoization and skips components it cannot optimize safely.
A practical order:
-
Enable the ESLint plugin first - before touching any code. Fix the violations it flags. Each violation is a purity issue or a rules-of-hooks issue that would prevent the compiler from running.
-
Enable the compiler with no other changes. Check DevTools to see what gets the
✨badge. -
Remove defensive memoization - start with
useMemocalls that wrap cheap operations, anduseCallbackcalls that only exist to satisfyReact.memoon a child. The compiler covers these automatically. React's docs recommend testing carefully here, because removing memoization can change the compiled output, so remove it in small batches. -
Profile before and after - use the React DevTools Profiler to confirm that the components you changed are not re-rendering more than before.
-
Keep targeted memoization - for the third-party library cases and expensive computations described above.
// Before migration - defensive boilerplate everywhere
function UserList({ users, onSelect }) {
const sorted = useMemo(
() => [...users].sort((a, b) => a.name.localeCompare(b.name)),
[users]
);
const handleSelect = useCallback(
(id: string) => onSelect(id),
[onSelect]
);
return (
<ul>
{sorted.map(user => (
<UserItem key={user.id} user={user} onSelect={handleSelect} />
))}
</ul>
);
}
// After migration - the compiler handles stability
function UserList({ users, onSelect }) {
const sorted = [...users].sort((a, b) => a.name.localeCompare(b.name));
return (
<ul>
{sorted.map(user => (
<UserItem key={user.id} user={user} onSelect={(id) => onSelect(id)} />
))}
</ul>
);
}The second version is both shorter and at least as performant - the compiler generates stable references for sorted and the inline arrow function automatically.
Write plain, pure components and let the compiler optimize
The compiler shifts the mental model: instead of writing components and then layering memoization on top, you write components that are pure and let performance follow from that.
In practice this means:
- No side effects in render. Move
console.log, mutations, and network calls intouseEffector event handlers. - No mutating props or state in place. Always create new objects and arrays when data changes.
- No external mutable singletons read during render. Values accessed in render should come from props, state, or constants.
Most of these are already part of the Rules of React. The compiler just enforces them more strictly and rewards compliance with automatic optimization.
Try it: press Add by mutation a few times. The plain list keeps up only because it re-renders anyway; the memoized one, which is what the compiler gives every component, keeps showing the old array. Add with a copy works in both.
import { memo, useState } from 'react';
import './styles.css';
const FRUITS = ['cherry', 'kiwi', 'mango', 'pear', 'plum'];
function FruitList({ items }) {
return (
<ul>
{items.map((fruit, i) => (
<li key={i}>{fruit}</li>
))}
</ul>
);
}
// Roughly what React Compiler does for you: skip the render if props are the same objects.
const MemoFruitList = memo(FruitList);
export default function App() {
const [items, setItems] = useState(['apple', 'banana']);
const [, forceRender] = useState(0);
const next = () => FRUITS[items.length % FRUITS.length];
// ❌ Mutates the array React already has, then re-renders the parent.
// The memoized list gets the same array object and skips the update.
const addByMutation = () => {
items.push(next());
forceRender((n) => n + 1);
};
// ✅ A new array: every list sees new props.
const addWithCopy = () => setItems([...items, next()]);
return (
<main>
<div className="buttons">
<button onClick={addByMutation}>Add by mutation</button>
<button onClick={addWithCopy}>Add with a copy</button>
</div>
<p>The array has {items.length} items.</p>
<div className="columns">
<section>
<h2>Plain component</h2>
<FruitList items={items} />
</section>
<section>
<h2>Memoized (like the compiler)</h2>
<MemoFruitList items={items} />
</section>
</div>
</main>
);
}The compiler doesn't change how React renders
Understanding the compiler is easier if you already know how React's render pipeline works. When a component re-renders, React calls the component function and reconciles the output against the previous virtual DOM. The compiler does not change this model - it makes the inputs to that process more stable, so reconciliation finds fewer differences and skips more work.
The commit phase, useEffect timing, and the Server/Client boundary in Next.js App Router are all unaffected. The compiler is purely a render-phase optimization.
Stop memoizing by default
React Compiler v1.0 automates most of what developers used to do manually with useMemo, useCallback, and React.memo.
- Enable it in your build config - it's opt-in in both Next.js and Vite
- Write pure components - no side effects or mutations in render
- Use the ESLint plugin to catch purity violations before they become runtime bugs
- Remove defensive memoization - the compiler covers the common cases
- Keep manual memoization for libraries that compare by identity and genuinely expensive computations; use the library's own hooks (like
useWatch) for interior mutability - Migrate incrementally - the compiler is additive and coexists with existing code
The goal is not to delete every useMemo in your codebase. It is to stop writing them by default and only reach for them when you have a specific reason.
Have a question, spotted a mistake or see it differently? I'd genuinely like to hear it.
Interview questions on this
All questionsRelated posts
All posts- , 12 min readReact Commit Phase: Sub-phases, Layout and Passive EffectsThe React commit phase runs before mutation, mutation and layout in one synchronous pass, then passive effects. Where each effect and its cleanup runs.
- , 7 min readReact Rendering ExplainedHow React rendering works under the hood: reconciliation, virtual DOM, batching, and what actually triggers a re-render.
- , 12 min readReact State Management: Zustand vs Jotai vs TanStack QueryWhich React state tool for which state: TanStack Query for server data, Zustand or Jotai for shared client state, useState for local and the URL for filters.


