Mastering the React Native Bridge & New Architecture
For years, React Native relied on an asynchronous JSON bridge to communicate between JavaScript code and native code. This meant all calls had to be serialized, queued, and deserialized. With the New Architecture, React Native introduces a direct, synchronous invocation pathway that removes this bottleneck.
1. What is the JavaScript Interface (JSI)?
JSI is a lightweight, general-purpose interface written in C++ that allows the JavaScript engine (Hermes) to invoke methods on native objects directly. Under the hood, JavaScript variables hold direct references to C++ pointers, allowing synchronous API calls (like synchronous database fetches or camera triggers).
2. Fabric and TurboModules
Fabric is the new UI renderer that executes layout computation synchronously across threads. TurboModules is the new native module system that lazy-loads native native code only when called, significantly reducing app launch times.
3. Enabling the New Architecture
To switch on the New Architecture in React Native, configure the flags in your platform-specific configuration files:
# android/gradle.properties
newArchEnabled=true# ios/Podfile
use_react_native!(
:path => config[:reactNativePath],
:hermes_enabled => true,
:new_arch_enabled => true
)