Installation
Install react-native-sherpa-onnx in your React Native project and configure platform-specific setup.Package Installation
Peer Dependencies
The library requires@dr.pogodin/react-native-fs for file operations:
If your project uses Yarn v3+ or Plug’n’Play, configure Yarn to use the Node Modules linker to avoid postinstall issues.
Yarn PnP Configuration
If using Yarn v3+ with Plug’n’Play, add this to your.yarnrc.yml:
.yarnrc.yml
Platform Setup
- iOS
- Android
iOS Setup
The sherpa-onnx XCFramework is not shipped in the npm package (size ~80MB). It is downloaded automatically when you runpod install.Install CocoaPods dependencies
Navigate to the
ios directory and install pods:The podspec automatically runs
scripts/setup-ios-framework.sh, which downloads the XCFramework from GitHub Releases. The version is pinned in third_party/sherpa-onnx-prebuilt/IOS_RELEASE_TAG.Verify framework download
The script downloads the XCFramework and libarchive sources. Libarchive is compiled from source as part of the Pod.You should see output similar to:
iOS Requirements
- iOS 13.0+
- Xcode 12.0+
- CocoaPods 1.10+
Framework Architecture
The XCFramework includes:- libsherpa-onnx-cxx-api.a - C++ API merged into the static library
- libarchive - Compiled from source for model archive extraction
- Support for all iOS architectures (arm64, x86_64 for simulator)
The framework is fetched from GitHub Releases and automatically cached by CocoaPods.
Advanced: Building the Framework Locally
If you need a custom sherpa-onnx build (e.g., different version or patches):- Build the XCFramework using the build-sherpa-onnx-ios-framework workflow steps
- Place it in
ios/Frameworks/before runningpod install - The Pod will use the local framework instead of downloading
Verify Installation
Test that the native library is loaded correctly:App.tsx
Requirements Summary
React Native
Version 0.70 or higher
Android
API 24+ (Android 7.0+)
iOS
iOS 13.0+, Xcode 12.0+
File System
@dr.pogodin/react-native-fs
Troubleshooting
iOS: Framework download fails
iOS: Framework download fails
Symptom: Pod install fails with “Failed to download sherpa-onnx XCFramework”Solution:
- Check your internet connection
- Verify the release tag exists in GitHub Releases
- Try manual download:
bash scripts/setup-ios-framework.sh - Check
third_party/sherpa-onnx-prebuilt/IOS_RELEASE_TAGfor the expected version
iOS: 'sherpa-onnx/c-api.h' file not found
iOS: 'sherpa-onnx/c-api.h' file not found
Symptom: Build fails with missing header filesSolution:
- Clean build folder:
cd ios && rm -rf build && rm -rf ~/Library/Developer/Xcode/DerivedData - Re-install pods:
bundle exec pod install --repo-update - Verify
ios/Frameworks/sherpa-onnx.xcframeworkexists
Android: Build fails with 'Could not resolve com.sherpa-onnx:...'
Android: Build fails with 'Could not resolve com.sherpa-onnx:...'
Symptom: Gradle sync fails with dependency resolution errorsSolution:
- Clear Gradle cache:
cd android && ./gradlew clean - Sync project:
./gradlew --refresh-dependencies - Check
android/build.gradlehasmavenCentral()repository
Yarn PnP: Module not found errors
Yarn PnP: Module not found errors
Symptom: Runtime errors with Yarn v3+ Plug’n’PlaySolution:
Add to Then run:
.yarnrc.yml:testSherpaInit() fails
testSherpaInit() fails
Symptom:
testSherpaInit() throws an errorSolution:- iOS: Run
cd ios && bundle exec pod install - Android: Run
cd android && ./gradlew clean build - Rebuild the app completely
- Check that peer dependencies are installed
Next Steps
Quick Start
Build your first STT or TTS example
Model Setup
Learn how to bundle and load models
API Reference
Explore the complete API
Example App
Run the full-featured example app