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.
The steps to use the React Compiler in Modern.js are as follows:
Modern.js does not officially support React 19 yet, but you can install react-compiler-runtime@rc
in React 17 or 18 projects to allow the compiled code to run on versions before 19.
Currently, the React Compiler only provides a Babel plugin, so you need to install babel-plugin-react-compiler
.
Register the Babel plugin in your Modern.js configuration file:
For detailed code, you can refer to the Modern.js & React Compiler example project