Turbo Modules: Type-Safe Native Code in React Native
Turbo Modules let your JS code call native APIs synchronously, skipping the slow async bridge. Use them to access device features or high-performance native libraries.
Why it exists
React Native's original architecture communicated between JavaScript and native code over an asynchronous, serialized bridge. This was a performance bottleneck and made it impossible for JS to call a native function and get a result back immediately. Turbo Modules were created to enable direct, synchronous communication.
The mental model
Instead of sending a message across a bridge and waiting for a callback, Turbo Modules give your JavaScript code a direct reference to a native object. Calling a method on this object in JS synchronously executes the corresponding native code. It feels like calling a local function, not sending a request over a network.
How it works
The process is spec-driven. First, you define the module's API in a TypeScript or Flow file. This spec acts as the source of truth. Second, you run a Codegen tool that reads your spec and generates boilerplate interface code for iOS (Objective-C++) and Android (Java). Third, you write the actual native implementation in Swift/Kotlin or Java/Objective-C, conforming to the generated interfaces. The React Native runtime then uses a C++ layer called the JavaScript Interface (JSI) to expose your native object directly to the JavaScript VM.
When to use it
Use Turbo Modules when building new native functionality for apps using React Native's new architecture. They are ideal for performance-sensitive tasks that require synchronous access to native APIs, such as reading a device setting instantly or wrapping a high-speed native computation library. Any new library intended for the modern RN ecosystem should use them.
When not to use it
If a well-maintained third-party library already solves your problem, use it. For simple, one-off native calls in older projects not using the new architecture, the legacy NativeModules system can be simpler to set up. Avoid them if you have no capacity to write or maintain native code (Swift/Kotlin/Java/Objective-C).
One canonical example
A common use case is creating a cross-platform persistent storage module. You would define a JS spec with setItem(key, value) and getItem(key). The Codegen would create the native interfaces. Your Android implementation would use SharedPreferences to store the data, while the iOS implementation would use NSUserDefaults. Your React Native code could then call storage.getItem('user-id') and get the value back synchronously.
Interview question
What is the primary advantage Turbo Modules offer for React Native applications?
- a.They automatically generate all necessary native implementations from a JavaScript specification.
- b.They simplify native module development by removing the need for platform-specific code.
- c.They enable JavaScript to communicate with native APIs synchronously, bypassing the asynchronous bridge.Correct
- d.They are primarily designed for older React Native projects not using the new architecture.
Why? this is the answer
Turbo Modules' core innovation is enabling direct, synchronous calls from JavaScript to native code, which improves performance by avoiding the asynchronous bridge. While they streamline the interface definition, they do not remove the need for platform-specific native code implementations.
Just read this? Test yourself on what you have been reading.
Read the original → github.com
- #react native
- #native modules
- #performance
- #mobile
Put your scrolling time to good use
Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on react native — each one lists the topics its interview covers.
See open roles