React Native Node is a powerful library that enables running a separate Node.js process alongside a React Native application. It provides a unique solution for developers who need to leverage Node.js functionality within their mobile applications.
- Isolated Node.js Process: Runs Node.js as a separate thread/process within a React Native app
- Cross-Platform Support: Works on Android platforms
- Background Execution: Allows Node.js code to run in the background of mobile applications
- Flexible Integration: Enables using Node.js modules and capabilities not typically available in mobile environments
The library solves the challenge of integrating Node.js functionality directly into React Native mobile applications. It creates a bridge that allows developers to:
- Execute Node.js code in a mobile context
- Run background services
- Utilize Node.js-specific libraries and tools within mobile apps
- Extend the capabilities of React Native beyond its standard runtime environment
- Seamless integration of Node.js and React Native
- Minimal performance overhead
- Simplified process of running complex backend logic in mobile apps
- Enhanced flexibility for developers working across web and mobile platforms
- React Native 0.47.0 or higher
- Node.js installed on your system
- For Android: Android SDK and development environment
- For iOS: Xcode and CocoaPods
Install the package using npm or yarn:
npm install react-native-node
# or
yarn add react-native-node- Open your project's
android/build.gradlefile and ensure the build tools are compatible. - Link the library to your React Native project:
react-native link react-native-node- Install CocoaPods if not already installed.
- Link the library to your React Native project:
react-native link react-native-nodeHere's a basic example of how to use react-native-node in your project:
import RNNode from 'react-native-node';
// Start a Node.js process in the background
RNNode.start('./background');
// Stop the Node.js process when no longer needed
RNNode.stop();To run the project in development mode:
# For React Native
yarn start
# Build the background Node.js process
yarn buildFor a production build, follow your React Native project's standard build process for Android and iOS.
- Ensure all dependencies are correctly installed
- Check that your Node.js version is compatible with the project
- Verify React Native version meets the minimum requirement (0.47.0)
The RNNode object provides methods for managing a Node.js runtime within a React Native application.
Starts the Node.js runtime with optional command-line arguments.
- Parameters:
args(optional): An array of strings representing command-line arguments to pass to the Node.js runtime. If not an array, an empty array will be used.
- Returns:
void
Example:
import RNNode from 'react-native-node';
// Start Node.js with no arguments
RNNode.start();
// Start Node.js with specific arguments
RNNode.start(['-e', 'console.log("Hello from Node.js")']);Stops the Node.js runtime.
- Parameters: None
- Returns:
void
Example:
import RNNode from 'react-native-node';
RNNode.stop();The library also exports RNNode as the default export, which can be imported directly:
import RNNode from 'react-native-node';- JavaScript
- Node.js
- React Native
- Cheerio
- Noderify
- Babel
- ESLint
- Yarn
- npm
- Android (Android SDK, Java)
- mkdirp (directory creation utility)
- path (file path utilities)
- tar (file archiving)
- yargs (command-line argument parsing)
- React Native CLI
- Gradle (for Android build)
- Supports React Native 0.47.0 and above
This library is officially deprecated. The recommended alternative is Node.js Mobile by Janea Systems, which offers similar functionality with broader support.
When troubleshooting, use adb logcat with specific tags to gain insights into the Node.js process:
adb logcat *:S nodejs:V ReactNative:V ReactNativeJS:VKey logging tags include:
RNNodeThread: Process start, termination, and error informationRNNodeService: Debugging for tar/untar and Node binary preparationRNNode: General library-related logs
- Android: Fully supported with Node.js v7.1.0
- iOS: Currently unsupported due to Apple's restrictions on Just-In-Time compilation
- Native package support is theoretical and depends on individual library implementations
- Most packages without Android-specific native bindings should work
- For complex native packages, compiling directly on an Android device using Termux is recommended
The library includes a prebuilt Node.js binary (bin_node_v710) compiled using the NodeBase approach. For enhanced security, consider:
- Reviewing the prebuilt binary
- Compiling the Node.js binary yourself if you have specific security requirements
This library was originally developed to support the Scuttlebutt ecosystem on mobile platforms, specifically for the mmmmm mobile app.
We welcome contributions to the project! Please follow these guidelines when contributing:
- Fork the repository and create your branch from
master - If you've added code that should be tested, add tests
- Ensure the test suite passes
- Make sure your code passes the linting checks
- Issue a pull request with a clear description of your changes
- Use ESLint for code style enforcement
- Follow the existing code formatting in the project
- Write clear, concise comments for complex logic
- The project requires React Native version 0.47.0 or higher
- Use
npmoryarnfor dependency management - Run
npm installoryarn installto set up the development environment
- Use GitHub Issues to report bugs or suggest features
- Provide a clear and detailed description
- Include steps to reproduce the issue if applicable
- Mention the version of react-native-node and React Native you are using
- The project is currently DEPRECATED
- Contributions are welcome, but major feature additions may not be merged
- Consider using Node.js Mobile for new projects
Contributions will be accepted under the MIT License, which is the current license of the project.
This project is licensed under the MIT License.
The MIT License is a permissive free software license that allows users to:
- Use the software commercially
- Modify the software
- Distribute the software
- Sublicense the software
- Use the software privately
Copyright (c) 2017-present André Staltz (staltz.com)
For the complete license text, see the LICENSE file in the repository.