NitroModules vs TurboModules
What is Nitro
So I will quote the main docs of NitroModules to explain what exactly it is :
Nitro is a framework for building powerful and fast native modules for JS. Simply put, a JS object can be implemented in C++, Swift or Kotlin instead of JS by using Nitro.
Now historically speaking (like since the 2022’s I dont know how historical is that by coding standards) TurboModules was the de-facto way of writing native modules. It boasted better performance than its predecessor Legacy Native Modules (How it gave these performance boost is a topic reserved for another post alltogether).
However in present day the benchmarks tell another story all together. Performance wise Nitro has Turbo beat and hence is slowly becoming the defacto way for people to implement their native modules (You can find the relevant benchmarks over here )
One benefit (kinda) of TurboModules
TurboModules is what is shipped with react-native core. So for all those particular about not wanting to increase the dependencies in their project this might make Turbo a more convenient choice for them. But for the rest of us who don’t care about adding another package with
npm i react-native-nitro-modules
go ahead and add Nitro to your project.
Swift Support
For all you iOS developers this probably could be the most interesting part of Nitro Modules. Nitro provides swift support compared to Turbo that bridges swift code through Objective-C code. What does this mean for developers is a significant decrease in writing boilerplate code. For Example take a look at this code here :
class HybridMath : HybridMathSpec {
var someValue: Double
}
compared to Turbo’s way of doing it :
@implementation RTNMath {
NSNumber* _someValue;
}
RCT_EXPORT_MODULE()
- (NSNumber*)getSomeValue {
return _someValue;
}
- (void)setSomeValue:(NSNumber*)someValue {
_someValue = someValue;
}
@end
This is possible because Nitro bridges Swift via a C++ interface
TypeSafe and Developer UX
Ok enough of theoretical blabbering let’s jump into the code and see one of the reasons why developers are liking Nitro so much. To start with we will have to make a nitro module now there are many ways of doing so but we will be using the create-nitro-module for this demonstration purposes
npx create-nitro-module@latest
We will be naming the package react-native-math for simplicity sake. Once generated navigate to the package
cd react-native-math
and you will find node_modules already present as well as the nitrogen directory with the bridging-code already generated so for our next step we will navigate to the example app directory and install its dependencies
cd example/
npm i
Now with that done we can open the android directory in Android studio and start editing the native code.
studio android/
Once the project is opened and the Gradle sync finally finishes (it takes forever sometimes) you will see the following files in your project

Now let’s try something fun, navigate over to the math.nitro.ts file and you will see something like this :
import { type HybridObject } from 'react-native-nitro-modules'
export interface Math extends HybridObject<{ ios: 'swift', android: 'kotlin' }> {
sum(num1: number, num2: number): number
}
now let’s add another function sub, that we would like to implement on the native side to subtract a number
import { type HybridObject } from 'react-native-nitro-modules'
export interface Math extends HybridObject<{ ios: 'swift', android: 'kotlin' }> {
sum(num1: number, num2: number): number
sub(num1: number, num2: number): number
}
After doing this we will have to regenerate the spec files by running
npm run codegen
Now if you were to head on over to Android Studio and see the spec file you would see something like this :

And the best part is now you will be seeing an error like this :

This is one of the many benefits of running codegen while developing in contrast to what Turbo does and run it only on App compile time. This provides TypeSafe and better context for developers jumping back and forth between the TypeScript code and the Native code.
These are just a few of the benefits of using Nitro over Turbo when creating native modules. If you found this interesting and would like to incorporate it into your upcoming projects do give a star to the Nitro repo and to learn more you can always refer to the Nitro docs they are a good starting point as well.