This is a monorepo that brings Node-API support to React Native, enabling native addons written in C/C++/Rust to run on React Native across iOS and Android.
IMPORTANT: Before working on any package, always check for and read package-specific copilot-instructions.md files in the package directory. These contain critical preferences and patterns for that specific package.
Core Flow: JS require("./addon.node") → Babel transform → requireNodeAddon() TurboModule call → native library loading → Node-API module initialization
See the README.md for detailed descriptions of each package and their roles in the system. Key packages include:
packages/host- Core Node-API runtime and Babel pluginpackages/cmake-rn- CMake wrapper for native buildspackages/cmake-file-api- TypeScript wrapper for CMake File API with Zod validationpackages/ferric- Rust/Cargo wrapper with napi-rs integrationpackages/gyp-to-cmake- Legacy binding.gyp compatibilityapps/test-app- Integration testing harness
- Custom Hermes: Currently depends on a patched Hermes with Node-API support (see facebook/hermes#1377)
- Prebuilt Binary Spec: All tools must output to the exact naming scheme:
- Android:
*.android.node/with jniLibs structure +react-native-node-api-modulemarker file - iOS:
*.apple.node(XCFramework renamed) + marker file
- Android:
This project uses Node.js v22.x LTS "Jod" (became LTS on October 29, 2024). The previous LTS was v20.x "Iron".
Important: When reviewing CI workflows or suggesting Node.js version changes:
- The current active LTS codename is "Jod" (v22.x), not "Iron" (v20.x)
- Use
lts/jod(lowercase) in GitHub Actions workflow files - Check https://nodejs.org/en/about/previous-releases for the latest LTS information
npm ci && npm run build # Install deps and build all packages
npm run bootstrap # Build native components (weak-node-api, examples)- TypeScript project references: Use
tsc --buildfor incremental compilation - Workspace scripts: Most build/test commands use npm workspaces (
--workspaceflag) - Focus on Node.js packages: AI development primarily targets the Node.js tooling packages rather than native mobile code
- No TypeScript type asserts: You have to ask explicitly and justify if you want to add
astype assertions.
The core magic happens in packages/host/src/node/babel-plugin/plugin.ts:
// Input: require("./addon.node")
// Output: require("react-native-node-api").requireNodeAddon("pkg-name--addon")For linking against Node-API in CMakeLists.txt:
include(${WEAK_NODE_API_CONFIG})
target_link_libraries(addon PRIVATE weak-node-api)Library names use double-dash separation: package-name--path-component--addon-name
- Individual packages: Some packages have VS Code test tasks and others have their own
npm testscripts for focused iteration (e.g.,npm test --workspace cmake-rn). Use the latter only if the former is missing. - Cross-package: Use root-level
npm testfor cross-package testing once individual package tests pass - Mobile integration: Available but not the primary AI development focus - ask the developer to run those tests as needed
Documentation: Integration details, platform setup, and toolchain configuration are covered in existing repo documentation files.