Configuration
React Compiler is designed to work out of the box with no configuration needed. Most users will not need to configure the compiler. However, if you need to customize its behavior, various configuration options are available.
You will learn
- Available configuration options
- How to configure the compiler
Configuration Options Overview
React Compiler accepts several options to customize its behavior. See the API reference for detailed documentation of each option.
compilationMode
- Controls which functions to compiletarget
- Specifies the React version for compatibility (17, 18, or 19)sources
- Limits compilation to specific files or directoriesgating
- Enables runtime feature flags for incremental adoptionlogger
- Configures logging output for debuggingpanicThreshold
- Sets when the compiler should halt on errorsnoEmit
- Disables code generation
Basic Configuration
Pass options to the Babel plugin:
// babel.config.js
module.exports = {
plugins: [
['babel-plugin-react-compiler', {
target: '18', // For React 18 compatibility
}],
],
};
Framework Examples
Next.js
// next.config.js
module.exports = {
experimental: {
reactCompiler: {
target: '18',
},
},
};
Vite
// vite.config.js
export default {
plugins: [
react({
babel: {
plugins: [
['babel-plugin-react-compiler', { /* options */ }],
],
},
}),
],
};
Learn More
For detailed documentation of all configuration options, see the React Compiler API reference.
For incremental adoption strategies using these options, see the incremental adoption guide.