React Compiler in Next.js
Next.js 16 ships built-in support for the React Compiler, now stable. The
compiler is a build-time tool that automatically memoises your components, so
you keep writing plain code and get fewer unnecessary re-renders with no manual
useMemo or useCallback.
Turn it on with a single option in next.config.ts:
// next.config.ts
import type { NextConfig } from 'next';
const nextConfig: NextConfig = {
reactCompiler: true,
};
export default nextConfig;
In Next.js 15 this lived under experimental; in 16 reactCompiler is a
stable, top-level option. It is not enabled by default, because the compiler
relies on Babel and raises compile times during development and builds. Install
the plugin alongside it:
npm install -D babel-plugin-react-compiler
Once enabled, the compiler analyses each component against the Rules of React
and inserts memoisation where it can prove the code is safe, skipping components
it cannot. Because the compiler does this automatically, the manual memo hooks
change role: useMemo, useCallback, and memo become escape hatches for
the rare cases that need precise control.
For the React Compiler itself — how it analyses components and what the Rules of React are — see the React Track's lesson. This lesson is about the Next.js switch.
You are about to answer a short quiz on reactCompiler.