React Native
On Android and iOS your C++ compiles to native libraries inside the app's Gradle and Xcode builds, and JavaScript calls them over JSI, with no WebAssembly. You import a header from a component, as on the web, and call it after initNative().
Set up
Install the runtime packages as dependencies, so React Native autolinks them, and the Metro plugin as a dev dependency. crossbind itself comes with @crossbind/plugin-react-native.
Android builds need Docker or a remote runner; iOS builds run on the Mac. Both need the mobile tools in Prerequisites. Add a crossbind.config.mjs at the project root; a port needs its -android and -ios packages, both installed and listed:
Your C++ goes in src/native. Import its header from a component and call it once initNative() resolves (Native is a class in src/native/native.h):
To start from a template instead: npm create crossbind@beta -- my-app Mobile "React Native" "Native CLI", or Expo as the last argument.
Metro
@crossbind/plugin-metro turns header, .i and .rs imports into JavaScript modules and writes the C++ bridge for each header while Metro bundles. Wrap the default config with it:
In a monorepo, also add the workspace root to watchFolders, or Metro cannot resolve the workspace packages.
iOS
iOS libraries build on the Mac itself, with the Xcode at /Applications/Xcode.app, for iOS 15.1 and later. Install the pods, then run the app:
pod install compiles your C++ into the react-native-crossbind pod, and a crossbind build phase rebuilds what changed before every Xcode build. Run pod install again when packages.conan changes.
crossbind build phase runs node by name, from Xcode's environment rather than your shell's. If it is not found there, link it once: ln -s $(which node) /usr/local/bin/node.Android
There is no separate step: npm run android builds the bridges and your C++ inside Gradle.
- ABIs:
arm64-v8aandx86_64, narrowed to the app'sreactNativeArchitectures. - CMake 3.28 or newer, which the plugin's CMake script requires.
- Your C++ compiles with the app's NDK at its
minSdkVersion, 24 when the app sets none. The port libraries come prebuilt from crossbind's Android image, built against API level 33.
Expo
Expo Go cannot load your C++, so the app needs native projects of its own, which expo prebuild generates. Install the same packages as above and add the config plugin to app.json before prebuilding:
During prebuild the plugin sets up the iOS project for crossbind: arm64 simulators only, iOS 15.1 at least, and the UIScene lifecycle iOS 27 requires. Wrap Expo's own Metro config; it exports no mergeConfig, so also install metro-config as a dev dependency (npm install --save-dev metro-config):
Expo's web build compiles the same imports to WebAssembly, single-threaded unless target.runtime is 'mt', which needs COOP/COEP headers from the host. Stage the web dependencies before Metro starts, and link the wasm in after an export:
Threads and files
Android and iOS builds are always multithreaded with the device's own threads: no headers are needed, and useWorker does not apply. target.runtime changes only the Expo web build.
C++ opens real files in the app's sandbox; there are no /opfs or /memfs mounts.
Release builds
The C++ compiles inside the app's own build, so a release build needs no extra step:
Limits
- React Native 0.81 or newer.
- iOS simulator builds are arm64 only, so they need an Apple silicon Mac.
- A function newly imported from a port's header works only after the next native build; until then the call fails with
... is not bound in the native module.
examples/mobile-reactnative-cli and examples/mobile-reactnative-expo are complete apps.