React Compiler
The React Compiler is an experimental compiler introduced in React 19 that can automatically optimize your React code.
Before starting to use the React Compiler, it is recommended to read the React Compiler documentation to understand its features, current status, and usage.
How to Use
React 19
If you are using React 19, Modern.js has built-in support for React Compiler, and no additional configuration is required.
React 18
If you are using React 18, you need to configure it as follows:
- Install
react-compiler-runtimeto allow the compiled code to run on versions before 19:
- Install
babel-plugin-react-compiler:
- Register the Babel plugin in your Modern.js configuration file:
modern.config.ts
For detailed code, you can refer to the Modern.js & React Compiler example project