Announcing Node-API Support for React Native

Authors
Kræn Hansen
Software Engineer
@
MongoDB
Mariusz Pasiński
Software Engineer
@
Callstack
Matt Hargett
Founder
@
Rebecker Specialties
Vladimir Morozov
Principal Engineer
@
Microsoft
Michał Pierzchala
Principal Engineer
@
Callstack
Mike Grabowski
CEO & Founder
@
Callstack
Jamie Birch
Engineer
@
Scoville, NativeScript TSC

Together with the community, we're bringing Node-API, the native module system developed and widely used in Node.js, into React Native. Node-API allows native code to interface with JavaScript in a runtime-independent and stable way. It’s used in production today across Node.js, Deno, Bun, and more.

By adopting Node-API in React Native, we gain a consistent, cross-platform foundation for building native modules. It supports multiple programming languages and is ABI-stable, making it easier to share, reuse, and maintain modules across projects and versions.

In this article, we dive deeper into the potential future of this module system, our motivation behind building it, and take a closer look at how it works and what it enables for the React Native ecosystem.

If you just want to see the code, we've published an example repo with a Node-API addon prebuilt for Node.js and React Native: https://github.com/callstackincubator/node-api-example-lib

Special thanks

Before we dig in, we need to acknowledge how this is truly a collaborative effort across the community.

Since Vladimir Morozov’s PR adding Node-API to Hermes and Jamie Birch’s talk at React Summit US ‘24 we’ve been meeting on a regular weekly cadence and worked together.

None of this would be possible without the attention and generous contributions from Vladimir (Microsoft), Jamie (NativeScript), Kræn (MongoDB / Independent), Matt Hargett (Rebecker Specialties) and numerous Callstack engineers - Mariusz (Mario) Pasinski in particular.

Motivation

Pre-builds that work across React Native versions

Today, most native modules for React Native are distributed as source, and so contribute significantly to the overall build time of apps. In fact, compiling native modules can constitute the majority of an app's build time, as we can see clearly on Android:

On iOS, it is the second-biggest build task after compiling React Native core. And as work is underway to distribute React Native iOS as a prebuilt binary (like Android), it will soon become the biggest one.

By distributing all native modules as prebuilds, apps could be built in as little as 7 seconds.

React Native and Hermes teams are actively working on ABI stability for JSI, and it's scheduled for React Native 0.81 (currently in RC). Once shipped, it will make such optimizations possible for everyone.

Existing ecosystem of Node-API compatible runtimes & languages

Node-API is the technology of choice for calling native code from JavaScript, for a number of runtimes, such as Node.js, Deno, and Bun. Being engine-agnostic, and with bindings from a variety of programming languages (e.g., C, C++, C#, Swift, Zig, Go, or Rust), it has become a popular tool for cross-ecosystem code-sharing, with countless modules available on npm today.

With Node-API being a part of the Node.js project (hosted by the OpenJS foundation) the longevity and healthy evolution of the specification is secured. We believe it’s here to stay and worth the effort for the React Native community to start investing into as well.

Because Node-API is a C API, any language with the ability to call a C-style foreign function interface (FFI) can call into it. Below are a few examples of a simple sum function implemented in different languages. Some (like Rust) are very concise as they leverage code-generation, and others (such as C++) are a bit more verbose.

C++

1#include <napi.h>
2
3Napi::Value Sum(const Napi::CallbackInfo& info) {
4  Napi::Env env = info.Env();
5
6  if (info.Length() < 2 || !info[0].IsNumber() || !info[1].IsNumber()) {
7    Napi::TypeError::New(env, "Expected two number arguments").ThrowAsJavaScriptException();
8    return env.Null();
9  }
10
11  double arg0 = info[0].As<Napi::Number>().DoubleValue();
12  double arg1 = info[1].As<Napi::Number>().DoubleValue();
13  double sum = arg0 + arg1;
14
15  return Napi::Number::New(env, sum);
16}
17
18Napi::Object Init(Napi::Env env, Napi::Object exports) {
19  exports.Set(Napi::String::New(env, "sum"),
20              Napi::Function::New(env, Sum));
21  return exports;
22}
23
24NODE_API_MODULE(SumAddon, Init)

Rust

A Rust Node-API Module exporting a sum() function, using the napi.rs binding generator. Example from here.

1#[napi]
2fn add(a: u32, b: u32) -> u32 {
3  a + b
4}

Swift

A Swift Node-API module exporting a sum() function. Heavily inspired by this example.

1import NAPI
2
3func sum(a: Double, b: Double) -> Double {
4    return a + b
5}
6
7@_cdecl("_init_function_arguments")
8func initFunctionArguments(env: OpaquePointer, exports: OpaquePointer) -> OpaquePointer? {
9    return initModule(env, exports, [
10        .function("sum", sum)
11    ])
12}

Existing ecosystem of Node-API native code

With React Native's push for Web conformance, it is vital to make use of existing work where possible. Many Web APIs, such as WebRTC, Web Audio, and Canvas, have been implemented with Node-API. The Hermes team sees this and is eager to adopt Node-API for implementing functionality such as Temporal and Intl.

Supporting Node-API interface will allow for unprecedented code sharing opportunities between the web and React Native ecosystem.

As the time of writing, our project has built-in support for Cmake-based C++ addons through our cmake-rn build tool, conversion of Gyp-based C++ addons through gyp-to-cmake and finally Rust through our ferric build tool.

Perfect use-cases

You would reach for Node-API, if you’re building an app or library and have code which is either:

  • shared across multiple platforms, potentially outside of React Native too: databases, sync-engine, shared business logic that you only want to implement once.
  • computationally costly: AI inference, classification, encryption, hashing, physics engines, digital signal processing using Fourier transformations or solving differential equations via Laplace transforms - the fun stuff!
  • calling into platform APIs: Through an Apple SDK, Android NDK or even JNI. Node-API prebuilds can call into any of the platform APIs provided by the platform build tools.
Using prebuilt Node-API for React Native is less ideal for apps and libraries with native code calling into React Native Core, since they face the same issue as JSI: not being ABI stable. It can be done, using a traditional “sibling” TurboModule or via the JavaScript boundary; which is fine, but potentially less performant.

Work in progress

The PR adding Node-API support to Hermes is a work-in-progress, although most of the actual code is being upstreamed from React Native Windows. Because of this, using React Native Node-API modules require building Hermes from source, using a patched version with the Node-API functions, which incidentally means the app will have to use specific versions of React Native (currently 0.79.1 or 0.79.2).

We expect this restriction to go away as soon as the PR adding Node-API support to Hermes is merged and pulled in by React Native core team.

At the time of writing, the Node-API host module supports only iOS and Android. We want to embrace out-of-tree platforms too and will be gradually extending support for these. Please, reach out if you're an expert on any of these and want to help implement or support this effort.

Join our effort and contribute!

If you, too, get excited about a future of native modules for React Native being prebuilt, fast and backed by binding-generators as well as increased collaboration across the JS ecosystem, we need your help!

You can find all the code and more documentation on how to get started with Node-API modules for React Native via https://github.com/callstackincubator/react-native-node-api

Express your excitement: Through posts and comments spreading the message, starring the repository and reacting with 👍 and 💙 as we continue to move this forward and release improvements.

Take it for a spin: Install an example Node-API into your app, try building a simple Node-API module to get a feel for the simplicity and bettered developer experience and, if you’re feeling particularly adventurous, fork and clone the repo to start working on a good first issue.

If you’re already authoring a native add-on for Node.js, try targeting React Native directly and if you’re already building a native module using JSI, try out the Node-API experience; we firmly believe the benefits from ease of developer experience and ease of maintenance is worth the efforts of switching over for many existing libraries.

We can’t wait to see what you build with this, and we’re here to help you make it happen!

Insights

Learn more about React Native

cover

Aug 4Podcast

VisionCamera V5 With Marc Rousavy

Marc Rousavy joins Mike Grabowski to unpack VisionCamera v5, Nitro Modules, the constraints API, migration work, and what changed for React Native camera apps.

cover

Jul 1Podcast

Redraw for Effects Beyond Skia

William Candillon talks about where Redraw fits next to Skia, from physics-based rendering to camera effects, AR, and new UI patterns.

cover

Jun 29Article

Less Boilerplate, More Type Safety: React Navigation 8's Typed Hooks

React Navigation 8 improves typed hooks with screen-aware types, less boilerplate, and fewer unsafe casts in shared UI and nested navigators.

cover

Apr 30Live Stream

Build a React Native App With the TanStack Stack

Join Callstack’s live stream on building a React Native app from the ground up using the TanStack toolbelt.

cover

Apr 28Article

React Native production lessons from React Universe Meetup x Zalando

Lessons from React Universe Meetup x Zalando on React Native in production, covering brownfield performance, feed video, native API access, and on-device AI.

cover

Apr 23Talk

Shipping iOS Live Activities with React: The Voltra Story

How Voltra enables Live Activities and Dynamic Island views using React without writing Swift. A deep dive into iOS constraints and architecture.

cover

Apr 16Live Stream

React Native 0.85: Animation Backend and Key Updates

A recap of React Native 0.85, covering the new animation backend, DevTools improvements, and ecosystem takeaways.

cover

Mar 5Article

Keeping Screens Visible With <Activity mode="hidden">

A cross‑platform workaround to keep screens visible while <Activity mode="hidden"> unmounts effects on inactive screens by setting mode="hidden".

cover

Feb 25Article

React Native Monorepo With pnpm Workspaces

Set up a React Native monorepo with pnpm workspaces for mobile and Next.js web, including Metro fixes, hoisted node-linker, and shared packages.

cover

Feb 18Article

A Practical Guide to React Native Monorepo With Yarn Workspaces

Learn how to set up a React Native monorepo with Yarn workspaces for mobile and web, including Metro, Gradle, and shared packages.

cover

Feb 17Podcast

From Teddy Bears to Voice Agents: Kraen Hansen on Voice AI, Local-First & App Security

What happens when you combine voice agents and teddy bears? A hands-on look at local-first systems, voice AI, and security lessons from poking real apps.

cover

Jan 28Article

Bringing CSS Clipping to React Native

A deep look at how a single CSS feature moves through React Native’s New Architecture, from JavaScript styles to native rendering on iOS and Android.

cover

Mar 19Tutorial

The Hard Way vs. The React Native AI SDK Way: Stop Writing Custom Modules for Every Model

Learn how React Native AI uses a unified provider model to switch between cloud and on-device LLMs without rewriting application logic, enabling reliable AI experiences online and offline.

cover

Mar 12Tutorial

Build Smarter Apps: Tool Calling & AI Orchestration Explained

Learn how on-device models in React Native can call tools, interact with external APIs, and return structured outputs you can use directly in application logic.

cover

Mar 5Tutorial

MLC LLM + React Native: On-Device AI Without the Pain

Learn how to run third-party on-device LLMs in React Native using MLC LLM. Choose your models, run them efficiently across platforms, and keep a unified JavaScript API with React Native AI.

cover

Feb 24Tutorial

Intelligent Fallbacks with Apple Intelligence in React Native

Learn how to use Apple’s built-in Foundation Models in React Native apps, reduce memory usage, and enable fast, fully on-device AI with React Native AI Apple.

cover

Feb 10Tutorial

What Is the React Native AI SDK? A Complete Intro & Quickstart

Learn why on-device AI matters for React Native apps, how local LLMs behave offline, and what problems React Native AI is designed to solve from day one.

cover

Jan 29Tutorial

Implementing an Android TurboModule with Kotlin

Learn how to implement a React Native TurboModule on Android, from the TypeScript spec and Codegen to the Kotlin implementation and package registration.

cover

Jan 19Tutorial

Working with Different Threads in Swift TurboModules

Learn how JavaScript, native module, background, and main threads interact in React Native TurboModules, and how to use GCD queues to run async work safely in Swift.

cover

Jan 9Tutorial

How to Add Type-Safe Constants to Swift TurboModules

Learn how to expose typed, immutable constants from a Swift TurboModule using Codegen, and get full end-to-end type safety between native and JavaScript.

cover

Dec 30Tutorial

Adding Event Emitters to Your TurboModule in Swift

Learn how to emit native events from a Swift TurboModule and subscribe to them in JavaScript, including proper memory management and Codegen integration.

cover

Dec 22Tutorial

Writing Your First TurboModule in Swift

Learn how to build a fully working TurboModule in Swift, integrate it with Codegen, and bridge it through Objective‑C inside an Expo app.