Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Node-API Modules for React Native

License

NotificationsYou must be signed in to change notification settings

callstackincubator/react-native-node-api

 
 

Repository files navigation

Node-API Modules
for React Native

Write once, run anywhere:
Build native modules forReact Native withNode-API.

Getting started

Warning

This library is still under active development. Feel free to hack around, but use at your own risk.

How does this work?

Note

This library is currently dependent on a custom version of Hermes and therefore has a very limited range of supported React Native versions.Once thePR adding Node-API support to Hermes merges, we expect this restriction to be lifted.

Note

This library only works for iOS and Android and we want to eventually support React Native for Windows, macOS, visionOS and other out-of-tree platforms too.

See the document on"how it works" for a detailed description of what it's like to write native modules using this package.

Packages

This mono-repository hosts the development of a few packages:

packages/react-native-node-api

Responsible for adding Node-API support to your React Native application:

  • Declares a Podspec which downloads a special version of Hermes, with Node-API support,
    • instructing React Native's Hermes Podspecs to compile from this custom source-code.
    • patching React Native's JSI copy, with the updates introduced by our special version of Hermes.
    • we expect this to eventually be removed, as Node-API support gets merged into Hermes upstream.
  • Automatically discovers and adds Node-API binaries, matching thethe prebuilt binary specification
    • This is driven by the platform specific build tools (through the Podspec on iOS and eventually Gradle on Android)
  • Implements a TurboModule with arequireNodeAddon function responsible for
    • Loading dynamic libraries
    • Node-API module registration and (perjsi::Runtime) initialization.
  • Provides ways of transformingrequire("./addon.node") andrequire("bindings")("addon") calls intorequireNodeAddon calls.

Note: We'll sometimes refer to this as the "host package", as it can be seen as a host of Node-API modules in React Native apps.

packages/cmake-rn

A wrapper around CMake making it easier to produceprebuilt binaries targeting iOS and Android matching thethe prebuilt binary specification.

Serves the same purpose ascmake-js does for the Node.js community and could potentially be upstreamed intocmake-js eventually.

packages/gyp-to-cmake

A tool to transformbinding.gyp files intoCMakeLists.txt files, intended forcmake-js orcmake-rn to build from.

packages/node-addon-examples

A wrapper around the examples in thenodejs/node-addon-examples repo, usinggyp-to-cmake andcmake-rn to prepare prebuilds and scaffolding for loading the addons.

The main purpose is to use these as tests to verify the implementation. We choose to use this as our first signal for compliance, over thejs-native-api tests in the Node.js project, because the examples depends much less on Node.js built-in runtime APIs.

apps/test-app

A test app usingreact-native-test-app to exercise the implementation of


[8]ページ先頭

©2009-2025 Movatter.jp