Nextjs Fundamentals · Next.js 16 Upgrade

React Compiler in Next.js

`reactCompiler`

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.

  1. Next.js 16 has built-in support for the React Compiler.
  2. Enable the React Compiler in `next.config` with `reactCompiler: ___`.
  3. The `reactCompiler` option is enabled by default in Next.js 16.
  4. In Next.js 16 `reactCompiler` is a top-level option, no longer nested under ___.
  5. With the React Compiler enabled, `useMemo` and `useCallback` become escape hatches.