Framework
React Native
New Architecture only. generate react-native writes a self-contained library into your app: TypeScript classes, member tables, the runtime, a Codegen spec, and build integration for Android (CMake) and iOS (CocoaPods).
How a call works
Intent.parseUri(...) / UIView.alloc().initWithFrame(...)
→ generated TypeScript → global.__nab (installed by one C++ Turbo Module)
→ Android: C++ runtime → JNI iOS: Objective-C++ runtime → NSInvocation
- Methods (not constructors or properties) also get a
…Async()Promise variant that runs off the JS thread; on iOS, UIKit members run on the main queue. long/NSIntegerarebigintinstrict-typescriptmode,numberinergonomic-typescript.- Java interfaces (Android) and Objective-C protocols (iOS,
Proto.implement({...})) can be implemented in JavaScript; Objective-C blocks are JavaScript functions; Kotlinsuspendfunctions return Promises;byte[]is aUint8Array;<NativeView>shows views created through the bindings. - Java exceptions,
NSError **failures and Objective-C exceptions become JavaScript errors with their native details.
One-time app setup
package.jsoncodegenConfigpointing at the generated spec (iOS also registersNabModuleProvider).- Android: include the generated CMake fragment and provide the module in
OnLoad.cpp. - iOS:
pod 'NativeApiBindings', :path => '../native-api-bindings'.
The generated library embeds the runtime. To depend on it instead, install native-api-bindgen-runtime from npm (npm install native-api-bindgen-runtime@beta).
The repository's examples/react-native/slice app does all of this. Its Showcase tab does real tasks (device dashboard, text-to-speech, share sheet, clipboard, persistent note, haptics) and its self-test suite passes 20 tests on the Android emulator and 19 on the iOS simulator (see Examples).
Measured
Release builds: about 1.50 µs per JSI → JNI call (Android emulator) and 1.14 µs per JSI → Objective-C call on the JS thread (iOS simulator); UIKit calls that hop to the main thread take about 10.0 µs. Metro does not tree-shake: the example's release APK is 19,312,390 bytes with bindings for its slice and 57,776,278 bytes with the whole Android SDK generated (baseline 18,623,666 bytes) — generate only what you use.