The base Babel transformer for Metro, the JavaScript bundler for React Native. Current stable version is 0.84.3, with frequent releases (~monthly). This package provides the default Babel transformation pipeline used by Metro to transpile JavaScript/TypeScript files. It handles caching, config merging, and integration with Metro's build system. Key differentiators: it is the official transformer maintained by Meta, tightly coupled with Metro's caching and dependency resolution; supports custom Babel configs; and ships TypeScript types natively since v0.83.5. Alternatives like @react-native/babel-transformer exist but this is the core package.
npm install metro-babel-transformerVerified import paths — ran on the pinned version, not inferred.
Shows how to use the transformer function directly: instantiate with project root, then call with file contents.
Upgrade Node.js to ^20.19.4 || ^22.13.0 || ^24.3.0 || >=25.0.0
Use `customTransformOptions` instead of `getTransformOptions`.
Update to v0.83.6 or later, or manually add your Babel config path to the cache key.
Run `npm install metro-babel-transformer --save-dev` and ensure your code uses the correct import.
Use `import MetroBabelTransformer from 'metro-babel-transformer'` instead of `import * as...`.
Install @babel/core: `npm install @babel/core --save-dev`