Home Blog Next-Gen Web and Frontend De React Compiler: no more useMemo explained
Next-Gen Web and Frontend De February 11, 2026 9 min read

React Compiler: no more useMemo explained

Next-Gen Web and Frontend De Enterprise Guide 2026 SCALE D2C D2C Technology Next-Gen Web and Frontend De Enterprise Guide 2026 SCALE D2C D2C Technology

The React Compiler, stabilised in React 19, automatically optimises React applications by analysing component code at build time and inserting memoisation where needed — eliminating the need for manual useMemo, useCallback, and React.memo calls. For most applications, this means a significant reduction in boilerplate and more consistent performance without developer effort.

What Is the React Compiler?

The React Compiler (previously known as React Forget) is a build-time compiler that transforms React component code to automatically add memoisation where React's rules of React guarantee it is safe to do so. The compiler analyses the data flow through your components — which values depend on which props and state — and inserts the equivalent of useMemo and useCallback calls to prevent unnecessary re-renders, without the developer needing to write or maintain that memoisation code manually.

Definition
The React Compiler is a build-time optimisation tool that automatically memoises React components and hooks according to React's rules, eliminating the need for manual useMemo, useCallback, and React.memo in most cases, while maintaining correct rendering behaviour.
Rendering performance improvement in React team internal apps
~0
Manual useMemo/useCallback calls needed in compiler-optimised code
React 19
Stable release version with compiler support

The Problem: Manual Memoisation Is Error-Prone

Before the React Compiler, preventing unnecessary re-renders required developers to manually wrap values in useMemo, functions in useCallback, and components in React.memo. This approach had three fundamental problems: it required developers to correctly identify which values needed memoisation (often non-obvious); it introduced bugs when dependency arrays were incorrect or stale; and it added significant boilerplate that obscured business logic.

// BEFORE React Compiler — manual memoisation required
function ProductList({ products, onSelect, filters }) {
  // Developer must remember to memoize every derived value
  const filteredProducts = useMemo(
    () => products.filter(p => filters.category === p.category),
    [products, filters.category]  // easy to get dependency array wrong
  );
  
  const handleSelect = useCallback(
    (id) => onSelect(id),
    [onSelect]  // boilerplate with no business value
  );
  
  return filteredProducts.map(p => (
    <ProductCard key={p.id} product={p} onSelect={handleSelect} />
  ));
}

// AFTER React Compiler — compiler handles this automatically
function ProductList({ products, onSelect, filters }) {
  const filteredProducts = products.filter(
    p => filters.category === p.category
  );
  
  return filteredProducts.map(p => (
    <ProductCard key={p.id} product={p} onSelect={onSelect} />
  ));
  // Compiler inserts memoisation automatically — same performance, no boilerplate
}

How the React Compiler Works

🔍
Static Analysis
The compiler parses your JavaScript/TypeScript source code into an AST (Abstract Syntax Tree) and performs static analysis of data flow — tracking which variables depend on which props and state values across component boundaries.
Rules of React Validation
The compiler validates that your code follows React's rules (no mutation of props/state, hooks called at top level, etc.). Components that violate the rules are skipped — the compiler only optimises code it can prove is safe to transform.
Automatic Memoisation Insertion
Where safe, the compiler inserts memoisation — wrapping derived values and callbacks in the equivalent of useMemo/useCallback with correctly computed dependency arrays. The transformed code is semantically equivalent to what an expert React developer would write manually.
🔄
Granular Re-render Prevention
The compiler achieves finer-grained memoisation than most developers achieve manually — it can memoize sub-expressions within JSX, individual object properties, and intermediate computed values that developers typically overlook when adding manual memoisation.

Setting Up the React Compiler

# Install the compiler babel plugin
npm install --save-dev babel-plugin-react-compiler

# For Vite projects — vite.config.ts
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

export default defineConfig({
  plugins: [
    react({
      babel: {
        plugins: ['babel-plugin-react-compiler'],
      },
    }),
  ],
});

# For Next.js — next.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
  experimental: {
    reactCompiler: true,
  },
};
module.exports = nextConfig;
💡 Incremental Adoption

You can adopt the React Compiler incrementally using the compilationMode: "annotation" option, which only compiles components explicitly annotated with "use memo" or "use forget" directives. This allows you to test the compiler on specific components before enabling it application-wide — useful for large codebases where you want to validate behaviour before a full rollout.

When the Compiler Skips Optimisation

The React Compiler only optimises code that follows React's rules. It will skip (leave unoptimised) components and hooks that: mutate props or state directly; call hooks conditionally; have side effects in render without useEffect; use patterns that violate referential transparency. The compiler emits warnings for skipped components, making it straightforward to identify and fix violations. The eslint-plugin-react-compiler package provides ESLint rules that catch violations at development time.

When to Still Use useMemo and useCallback

ScenarioCompiler Handles?Recommendation
Computed values from props/state✅ YesRemove manual useMemo — compiler is more accurate
Event handlers passed as props✅ YesRemove useCallback boilerplate
Expensive pure computations (sorting large arrays)✅ YesCompiler handles — but verify with React DevTools Profiler
Values passed to non-React dependencies (e.g., charting libs)⚠️ PartialMay still need manual memo for external library stability
Context values to prevent consumer re-renders✅ YesCompiler optimises context consumers automatically
Referential equality required by useEffect deps✅ YesCompiler ensures stable references — simpler useEffect code

React 19 Companion Features

The React Compiler ships as part of the broader React 19 release, which also includes: the Actions API for async state transitions without useReducer boilerplate; use() hook for reading context and promises in render; useOptimistic for optimistic UI updates with automatic rollback; Document Metadata support (<title>, <meta> directly in components); and improved Server Actions for full-stack React applications in Next.js and Remix.

Frequently Asked Questions

The React Compiler is a build-time tool that transforms your React component code to automatically add memoisation — preventing unnecessary re-renders — without you writing useMemo, useCallback, or React.memo manually. It analyses the data flow through your components at compile time, determines which values depend on which props and state, and inserts memoisation code that is equivalent to what an expert React developer would write by hand. The key difference is that the compiler is more thorough (it memoizes sub-expressions developers typically miss) and cannot make mistakes in dependency arrays (a common source of bugs in manually written useMemo/useCallback code).

Not immediately, but over time yes, for most cases. When you enable the React Compiler, it takes over memoisation responsibility — your existing useMemo and useCallback calls are redundant and add noise. The React team recommends running the compiler alongside your existing code initially, using React DevTools Profiler to verify no regressions, then progressively removing manual memoisation. The react-compiler-healthcheck tool can audit your codebase and identify components the compiler successfully optimises, giving you confidence to remove manual memoisation there. Keep manual memoisation only for rare cases where external library stability requires it.

The Rules of React are a set of constraints that React components and hooks must follow for React's rendering model to work correctly: components must be pure functions (same inputs always produce same outputs); props and state must not be mutated directly; hooks must be called at the top level (not inside conditions or loops); and components must not produce side effects during rendering (only in event handlers or effects). The React Compiler enforces these rules because it can only safely insert memoisation into code that follows them — if a component mutates its inputs, the compiler cannot determine when it is safe to skip re-rendering. Components that violate the rules are simply skipped by the compiler and left unoptimised.

Yes, the React Compiler fully supports TypeScript. The compiler processes TypeScript source files and performs its analysis on the TypeScript AST, respecting type information to improve its analysis accuracy. The babel-plugin-react-compiler handles TypeScript transformation as part of the build pipeline alongside your existing TypeScript configuration. The eslint-plugin-react-compiler also supports TypeScript projects for identifying Rules of React violations at development time. TypeScript's strict mode is recommended, as it helps surface the kinds of patterns (prop mutation, unsafe any usage) that would cause the compiler to skip components.

Yes, Next.js added React Compiler support in Next.js 15 via the experimental.reactCompiler option in next.config.js. Set reactCompiler: true to enable it for your entire application. Next.js also supports incremental adoption with the compilationMode option. The compiler works with both client components and server components in the App Router. For Pages Router applications, it applies to all page components. Next.js 15 also ships with React 19 support, so you get the full React 19 feature set including Actions, use(), and useOptimistic alongside the compiler optimisations.

The primary debugging tool is React DevTools (browser extension), which shows a flame chart of re-renders and highlights components that were skipped during rendering due to memoisation. The React DevTools Profiler "Highlight updates" feature visually shows which components re-rendered during an interaction — you should see significantly fewer highlighted components after enabling the compiler. The eslint-plugin-react-compiler reports Rules of React violations in your IDE, explaining why the compiler cannot optimise specific components. The compiler also outputs build-time warnings for skipped components, which you can address to increase compiler coverage. Start with small component trees and verify behaviour before enabling the compiler application-wide.

The React team reports approximately 2× rendering performance improvement in their internal applications (including the Instagram web app) after enabling the React Compiler. The improvement is larger in applications with significant prop drilling, complex component trees, and expensive render functions — and smaller in applications that already had comprehensive manual memoisation. The compiler's advantage over manual memoisation is that it applies more granular memoisation (sub-expression level) that developers typically miss, and it is applied consistently across all components rather than only those that developers identified as performance-critical. Real-world results vary by application — measure with React DevTools Profiler before and after to quantify improvement.

React Forget was the internal code name used by the React team for the auto-memoisation compiler project during its multi-year development period. The project was publicly discussed from 2021 onwards but remained in research and development, being used internally at Meta before public release. When the project reached stability for public release as part of React 19, it was renamed the React Compiler to better describe its function and scope (a compiler that does more than just memoisation, with plans for future optimisations). They are the same technology — React Forget is the historical name, React Compiler is the current public name.

REACT COMP

Ready to Implement React Compiler: no more useMemo explained?

Our specialist team delivers measurable ROI from Next-Gen Web and Frontend De programmes for enterprise and D2C brands.

Free Audit