Skip to content

About

🔥 Insanely fast native C++, Swift or Kotlin modules with a statically compiled binding layer for React Native

Topics

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Nitro Modules

Nitro Modules are fast, type-safe native modules for React Native with statically compiled bindings to JSI. They consist of two parts:

  • react-native-nitro-modules: The React Native package and native build integration for Nitro Modules
  • nitrogen: An optional code-generator for nitro module library authors

Example

Declaration (TypeScript):

export interface Math extends HybridObject<{ ios: 'c++' }> {
  add(a: number, b: number): number
}

Implementation (C++, Swift or Kotlin):

class HybridMath: public HybridMathSpec {
public:
  HybridMath(): HybridObject(TAG) {}
  double add(double a, double b) override {
    return a + b;
  }
}

Usage (TypeScript):

import { NitroModules } from 'react-native-nitro-modules'

const math = NitroModules.createHybridObject<Math>('Math')
const result = math.add(5, 3)

Installation

Install react-native-nitro-modules from npm:

npm i react-native-nitro-modules
cd ios && pod install

Documentation

Supported Platforms

Cross-platform

Cross-platform native modules can be built with C++. Any custom C++ types can be used and bridged to JS with minimal overhead.

JS <-> C++ type converters are statically generated ahead of time - no more dynamic lookups or runtime parser errors! 🥳

iOS

iOS native modules and view components can be written either in pure C++, or pure Swift. Thanks to Swift 5.9, Swift Nitro Modules bridge directly to C++ instead of going through Objective-C message sends. Woohoo, no more Objective-C, and zero overhead C++ -> Swift calls! 🥳

Android

Android native modules and view components can be written either in pure C++, or pure Kotlin/Java. Thanks to fbjni, even complex types can be effortlessly bridged to Kotlin/Java with minimal overhead! 🔥

Margelo

Nitro is built with ❤️ by Margelo. We build fast and beautiful apps. Contact us at margelo.com for consultancy services.

Contributing

This repository owns the React Native package, apps, test modules, and templates. Shared runtime sources, Nitrogen, and the docs live in margelo/nitro. The nitro-core package contains both native sources and the shared JS/TS API; this wrapper uses an exact matching version.

Run bun bootstrap to prepare dependencies and build the workspace, or bun bootstrap:ios to also install the example app's iOS dependencies. bun sync-core copies native sources from the installed nitro-core package into the existing RN package paths before builds and packing. Shared implementation changes belong in the Nitro repository. RN bootstrap, views, and worklets integration remain here.

Until the first npm release of the new core package is available, bootstrap uses the pinned packages/react-native-nitro-modules/nitro/ submodule as a temporary workspace source. The release adoption workflow removes that bootstrap dependency when it switches to published packages.

Read CONTRIBUTING.md for the contribution flow (PR expectations, the required test-per-fix rule, and the nitrogen workflow). For environment setup and reproduction walkthroughs, see the contributing guide on the docs site.

License

MIT

About

🔥 Insanely fast native C++, Swift or Kotlin modules with a statically compiled binding layer for React Native

Topics

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Contributors

Languages