Prerequisites
Before installing React Native ExecuTorch, ensure your project meets these requirements:
Requirement Minimum Version iOS 17.0 Android 13 (API level 33) React Native 0.81
Installation
Install core package
npm install react-native-executorch
Install resource fetcher
npm install @react-native-executorch/expo-resource-fetcher
npm install expo-file-system expo-asset
npm install @react-native-executorch/bare-resource-fetcher
npm install @dr.pogodin/react-native-fs @kesha-antonov/react-native-background-downloader
Install core package
yarn add react-native-executorch
Install resource fetcher
yarn add @react-native-executorch/expo-resource-fetcher
yarn add expo-file-system expo-asset
yarn add @react-native-executorch/bare-resource-fetcher
yarn add @dr.pogodin/react-native-fs @kesha-antonov/react-native-background-downloader
Install core package
pnpm add react-native-executorch
Install resource fetcher
pnpm add @react-native-executorch/expo-resource-fetcher
pnpm add expo-file-system expo-asset
pnpm add @react-native-executorch/bare-resource-fetcher
pnpm add @dr.pogodin/react-native-fs @kesha-antonov/react-native-background-downloader
Install dependencies
Make sure you’ve installed the resource fetcher and its dependencies: yarn add @react-native-executorch/expo-resource-fetcher
yarn add expo-file-system expo-asset
Run prebuild (if needed)
If using Expo with custom native code:
Run your app
# For iOS
npx expo run:ios
# For Android
npx expo run:android
Expo projects require expo-file-system and expo-asset for downloading and managing model files.
Install dependencies
Make sure you’ve installed the resource fetcher and its dependencies: yarn add @react-native-executorch/bare-resource-fetcher
yarn add @dr.pogodin/react-native-fs @kesha-antonov/react-native-background-downloader
Install iOS pods
cd ios && pod install && cd ..
Run your app
# For iOS
npx react-native run-ios
# For Android
npx react-native run-android
Bare React Native projects use @dr.pogodin/react-native-fs for file system operations and @kesha-antonov/react-native-background-downloader for background downloads.
Initialize ExecuTorch
After installation, initialize ExecuTorch in your app’s entry point (e.g., App.tsx or _layout.tsx):
import { initExecutorch } from 'react-native-executorch' ;
import { ExpoResourceFetcher } from '@react-native-executorch/expo-resource-fetcher' ;
initExecutorch ({
resourceFetcher: ExpoResourceFetcher ,
});
Call initExecutorch() before using any AI models or hooks. A good place is at the top level of your app, before component rendering.
Verify Installation
To verify the installation is working correctly, try importing the library:
import { useLLM , LLAMA3_2_1B } from 'react-native-executorch' ;
function TestComponent () {
const llm = useLLM ({ model: LLAMA3_2_1B , preventLoad: true });
console . log ( 'ExecuTorch initialized:' , llm !== null );
return null ;
}
If there are no errors, you’re ready to start using React Native ExecuTorch!
Common Issues
New Architecture Not Enabled
If you see errors about TurboModules or Fabric, ensure the New Architecture is enabled:
In ios/Podfile, ensure: ENV [ 'RCT_NEW_ARCH_ENABLED' ] = '1'
In android/gradle.properties, ensure:
Android Minimum SDK
If you encounter SDK version errors on Android, verify in android/build.gradle:
minSdkVersion = 33 // Android 13
iOS Deployment Target
For iOS version errors, check ios/Podfile:
Module Not Found Errors
If you see “Module not found” errors:
Clear your package manager cache:
# npm
npm cache clean --force
# yarn
yarn cache clean
# pnpm
pnpm store prune
Reinstall dependencies:
rm -rf node_modules
yarn install
Clean and rebuild:
# iOS
cd ios && rm -rf Pods Podfile.lock && pod install && cd ..
# Android
cd android && ./gradlew clean && cd ..
Next Steps
Quickstart Guide Build your first AI-powered feature with React Native ExecuTorch