How to enable React Compiler for React 18 Page Router Application? #86702
-
SummaryI'm on When I search for a solution to that error I see this page on React's docs about making React Compiler targeting React 18 instead of 19 (which is the default): https://react.dev/reference/react-compiler/target. Do we need to follow these instructions as well? Those instructions have us install Additional informationNo response ExampleNo response |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
|
I'd love to hear an answer to this as well. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
Hey @BruceHubbard , solid question—React Compiler's React 18 setup trips folks up since it defaults to 19 mode. Quick fix:
If Turbopack's in play and it still flakes, add the alias @icyJoseph shared. |
Beta Was this translation helpful? Give feedback.

Hey @BruceHubbard , solid question—React Compiler's React 18 setup trips folks up since it defaults to 19 mode.
Quick fix:
Install the runtime:
npm install react-compiler-runtime@latestUpdate
next.config.mjslike this (options pass straight to the Babel plugin):Grab the plugin if missing:
npm install -D babel-plugin-react-compiler@latestRestart dev server. That should kill the import error. Works for Pages Router too (docs lag a bit).
If Turbopack's in play and it still flakes,…