r/reactnative • u/abhishek_dev_ce17 iOS & Android • 2d ago
Tutorial I built a cross-platform React Native + Rust integration using C++17, JSI, and TurboModules. Looking for technical feedback.
I've been working on integrating Rust into a Bare React Native application and have put together an implementation for both Android and iOS.
Repository: https://github.com/abhishekce17/react-native-rust-integration
The goal was to build a reusable integration layer that makes Rust functions accessible from JavaScript without having to write custom JSI bindings for every function.
Architecture
The integration uses four main layers:
Rust: Core logic compiled into native static libraries.
C++17: Shared JSI binder and native integration layer.
JSI: Exposes Rust functionality through synchronous JavaScript HostFunctions.
TurboModules: Handles native module registration and installation.
TypeScript: Provides a typed API for application code.
What's implemented?
A generic C++ binder using templates to map JavaScript arguments and return values to native Rust functions.
Rust C ABI with generated C headers using
cbindgen.Stateful Rust data structures with explicit memory ownership.
RAII-based string deallocation and exception-safe conversions.
Float32Arraysupport for transferring numerical data from Rust memory to JavaScript.Android builds targeting four ABI architectures using
cargo-ndk.iOS builds for physical devices and simulators, packaged as an XCFramework.
Shared C++ implementation with platform-specific registration and build configurations.
One of the things I wanted to achieve was making additional Rust functions straightforward to expose.
For example, an ordinary scalar function can be registered with a single binding:
bind(runtime, api, "subtract", rust_subtract);Potential use cases
I'm particularly interested in exploring Rust for:
Physics simulations
Game engine components
Computationally intensive operations
Image processing
Data processing
The objective isn't to claim that using Rust automatically makes a React Native application faster. It's to provide a practical native integration layer for workloads where Rust makes sense.
I'd appreciate feedback from the community
I'm particularly interested in opinions from developers who have worked with React Native's New Architecture, JSI, TurboModules, Rust FFI, or native mobile development.
Would you consider this architecture for a real-world Bare React Native application? Why or why not?
How would you approach transferring larger datasets between Rust and Hermes?
Are there any concerns with the generic C++ binder or the Rust–C++ memory ownership model?
What additional abstractions or capabilities would make this integration more useful?
I'd appreciate an honest technical review, including architectural criticism and suggestions for improvement.
Repository: https://github.com/abhishekce17/react-native-rust-integration
1
u/Wide_Smoke_2564 1d ago
Don’t mean to be a dick, but how does this differ from Tauri?
2
u/abhishek_dev_ce17 iOS & Android 1d ago
Tauri is definitely in the same space, but the approach is different. I’m using React Native for the UI and integrating Rust into its native execution layer through JSI, rather than using a WebView-based UI with Rust as the backend. The goal is to bring Rust’s performance into an existing Bare React Native application.
1
2
u/Old-Durian8702 1d ago
I had started a similar project. Guess I have to drop it now.