react-native-codegen is an essential internal tool within the React Native ecosystem, responsible for generating native code (Java, Objective-C++, C++) from JavaScript type definitions (Flow or TypeScript). These generated definitions form the basis of "TurboModules" and "Fabric Components" in React Native's New Architecture, enabling type-safe, performant communication between JavaScript and native platforms. It primarily operates at build time, invoked by the React Native CLI, to automatically create the necessary bridging code for native modules and UI components. The package versioning is tightly coupled with the React Native monorepo, with the latest stable versions generally mirroring the `react-native` package's minor version (e.g., `react-native-codegen@0.85.x` for `react-native@0.85.x`). Its release cadence follows the React Native release schedule, typically bi-monthly or quarterly for minor versions. It differentiates itself from older bridging mechanisms by providing a standardized, strongly-typed, and automatically generated interface, significantly reducing boilerplate and improving developer experience and performance for native module authors.
npm install react-native-codegenVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to define a TurboModule spec file using TypeScript, which `react-native-codegen` processes to generate native code, and how to trigger the generation via the React Native CLI.
Consult the React Native 'New Architecture' migration guide and adapt native module definitions to use the codegen-compatible Flow or TypeScript spec files. Ensure your native module code implements the generated interfaces.
Always install `react-native-codegen` as a `devDependency` and ensure its version aligns with the `react-native` version specified in your `package.json`. It's usually managed automatically by the `react-native` CLI.
Always consult the official React Native documentation and migration guides for specific `react-native` releases to ensure your spec files remain compatible with the current `react-native-codegen` expectations. Keep your spec files as close to the provided examples as possible.
Verify your `package.json` scripts and CI/CD pipelines correctly invoke the codegen command. Incorrect `project-root` or missing platform flags can lead to missing generated files and subsequent native build errors.
Ensure `Int32` and similar types are only used within the `TurboModule` or `FabricComponent` spec files. For regular JavaScript/TypeScript, use standard number types. Also, verify your TypeScript `tsconfig.json` or Flow config properly recognizes the codegen type definitions.
Inspect the console output preceding the error for more specific messages (e.g., parsing errors, unsupported types, file access issues). Double-check your spec files for syntax errors and ensure all required tools (e.g., `clang`, Java SDK) are correctly installed and configured in your environment.
Run `npm install` or `yarn install` to ensure all dependencies are correctly linked. Verify your `react-native-codegen` version is compatible with your `react-native` version. If using custom scripts, ensure the import path precisely matches the package's internal structure for that version.
Review the official React Native documentation for the exact syntax required for TurboModule and Fabric Component spec files. Ensure you are using the correct type annotations and interface definitions as expected by `react-native-codegen`.
No dependency data recorded yet.