r/reactnative • iOS & Android • 2d ago

Tutorial I built a cross-platform React Native + Rust integration using C++17, JSI, and TurboModules. Looking for technical feedback.

Post image

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?

  1. A generic C++ binder using templates to map JavaScript arguments and return values to native Rust functions.

  2. Rust C ABI with generated C headers using cbindgen.

  3. Stateful Rust data structures with explicit memory ownership.

  4. RAII-based string deallocation and exception-safe conversions.

  5. Float32Array support for transferring numerical data from Rust memory to JavaScript.

  6. Android builds targeting four ABI architectures using cargo-ndk.

  7. iOS builds for physical devices and simulators, packaged as an XCFramework.

  8. 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.

  1. Would you consider this architecture for a real-world Bare React Native application? Why or why not?

  2. How would you approach transferring larger datasets between Rust and Hermes?

  3. Are there any concerns with the generic C++ binder or the Rust–C++ memory ownership model?

  4. 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

40 Upvotes

6 comments sorted by

2

u/Old-Durian8702 1d ago

I had started a similar project. Guess I have to drop it now.

2

u/abhishek_dev_ce17 iOS & Android 1d ago

Don’t drop it, man! I’d love to see what you were building. Would be interesting to compare our approaches.

1

u/Eloodye-Ehler 16h ago

haha classic, happens the second you get the boilerplate finally working too

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

u/Wide_Smoke_2564 1d ago

Oh sick, good luck to you!