C++ as React Native's Cross-Platform Engine
C++ is the shared engine under React Native's New Architecture, powering JSI and cross-platform TurboModules. One C++ module replaces separate Android and iOS native code.
WHY IT EXISTS: React Native's original architecture used a single-threaded async bridge that serialized all native calls as JSON. This created a bottleneck for large data transfers and made synchronous native access impossible. The New Architecture needed a cross-platform native layer that Android and iOS could both interface with directly, without forcing every module to be rewritten twice in Java and Objective-C. C++ became that common denominator because both platforms already maintain robust C++ interop layers, and it allows direct memory sharing with the JavaScript engine via JSI.
THE MENTAL MODEL: Think of C++ in the New Architecture as the universal adapter in a charging cable. Instead of building a separate Android cable and iOS cable that both talk to a slow translation desk, you write one C++ module that plugs straight into the JavaScript engine on both sides. JSI exposes HostObjects as C++ classes, so your native code lives in the same memory space as the JS runtime. There is no bridge queue, no JSON parsing, and no waiting for the next batch.
HOW IT WORKS: The JavaScript Interface is a lightweight C++ API that replaces the old bridge. When JavaScript calls a TurboModule method, JSI looks up a C++ HostObject and invokes it directly. Fabric, the new renderer, also runs its shadow tree operations in C++ inside the ReactCommon core, diffing trees and calculating layout before handing platform-specific views to Android or iOS. On Android, JNI binds the C++ layer to Kotlin or Java. On iOS, Objective-C++ provides direct interoperability with Swift or Objective-C. Because the core logic is C++, the same code executes on both platforms.
WHEN TO USE IT: Reach for C++ when you need a cross-platform native module that must run on both Android and iOS with identical behavior. It is also the right choice for performance-critical work like real-time audio processing, image manipulation, or cryptography where avoiding bridge serialization overhead matters. If you need synchronous access to native state from JavaScript, C++ TurboModules expose that capability safely through JSI.
WHEN NOT TO USE IT: Avoid C++ if your module is UI-heavy and deeply tied to platform-specific APIs like Android RecyclerViews or iOS CoreAnimation, because you will still need platform view managers. Do not introduce C++ if your team lacks build expertise, since debugging template errors, ODR violations, or STL mismatches across shared libraries can consume days. If the feature is Android-only or iOS-only, writing Kotlin or Swift is simpler and compiles faster.
ONE CANONICAL EXAMPLE: A cross-platform image resizing TurboModule written entirely in C++ using OpenCV or a custom codec. The same C++ source compiles into an Android library via CMake and an iOS framework via Xcode, exposing a single resize method to JavaScript through JSI. The JS thread calls it synchronously, receives a resized buffer, and never pays the cost of base64 serialization across the old bridge.
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.