@react-native-oh/react-native-harmony-cli
The CLI tooling package for React Native for OpenHarmony (RNOH) — provides project scaffolding, code generation, bundling and device commands for building React Native apps on HarmonyOS.
Requirements
- Node.js >= 20
- A React Native project using
@react-native-oh/react-native-harmony at the same version line as this CLI package (both packages of a line are released and installed together)
metro — the version range is pinned via peerDependencies
- DevEco Studio and OpenHarmony SDK — required by the device commands:
run-harmony invokes hvigor, ohpm and hdc from the DevEco/SDK toolchain and requires DEVECO_SDK_HOME to be set; pure JS commands such as bundle-harmony and codegen-harmony run without them
Installation
The CLI package is versioned jointly with the main package — install it at the same version line as @react-native-oh/react-native-harmony, via the same dist-tag (replace 0.XX with your version line):
npm install @react-native-oh/react-native-harmony@0.XX-stable \
@react-native-oh/react-native-harmony-cli@0.XX-stable
Run npm view @react-native-oh/react-native-harmony-cli dist-tags to list the available lines, or browse the main package versions on npm to see the live dist-tags.
⚠️ Do not install the CLI package without a tag: plain npm install @react-native-oh/react-native-harmony-cli resolves to latest, which may belong to a different version line than the main package in your project.
Commands
The commands register through the react-native CLI config, so run them as:
npx react-native <command>
| Command |
Description |
init-harmony |
Initializes a new RNOH project (generates the HarmonyOS native project) |
run-harmony |
Builds your app and starts it on a HarmonyOS device or emulator |
bundle-harmony |
Creates the JS bundle (or Hermes HBC bundle), generates the C++ header containing the JS code, and copies assets to the project |
codegen-harmony |
Generates boilerplate, types, and utilities from TurboModule/Fabric Component specs (runs during the application build process) |
codegen-lib-harmony |
Same as above, for library developers who ship generated code inside their libraries |
link-harmony |
Handles automatic linking of RNOH libraries (used by the RNOH Hvigor plugin) |
clean-harmony |
Removes cached files in the OpenHarmony project |
verify-package-harmony |
Validates that an npm package is compliant with RNOH library guidelines |
Run npx react-native <command> --help for the full option list of each command.
Documentation
Versioning
Versions are managed jointly with the main package @react-native-oh/react-native-harmony: the version format is RN_MAJOR.RN_MINOR.HARMONY_PATCH, and both packages of the same version line are released with the same version number. See the RNOH npm Package Management Specification.
Support
Found a bug or have a feature request? Please open an issue in the RNOH repository.
License
MIT. See the LICENSE file in the repository.