React Compiler with Nx
React 19 comes with an experimental compiler that optimizes application code to automatically memoize code. Read the official React Compiler documentation for more information.
Enabling React Compiler in Nx Projects
For Nx projects using Babel and the @nx/react/babel
preset, install the babel-plugin-react-compiler
package and the compiler will be enabled automatically. You can pass compiler options to the preset if needed.
1{
2 "presets": [
3 [
4 "@nx/react/babel",
5 {
6 "runtime": "automatic",
7 "reactCompiler": {
8 "compilationMode": "annotation"
9 }
10 }
11 ]
12 ],
13 "plugins": []
14}
15
You can also turn the compiler off with "reactCompiler": false
, even if babel-plugin-react-compiler
is installed.
Check the React Compiler usage docs for all support setups, such as Vite, Remix, etc.