Skip to main content

Prerequisites

Before installing React Native ExecuTorch, ensure your project meets these requirements:
New Architecture Required: React Native ExecuTorch only supports the New React Native Architecture.
RequirementMinimum Version
iOS17.0
Android13 (API level 33)
React Native0.81

Installation

1

Install core package

npm install react-native-executorch
2

Install resource fetcher

npm install @react-native-executorch/expo-resource-fetcher
npm install expo-file-system expo-asset

Platform-Specific Setup

1

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
2

Run prebuild (if needed)

If using Expo with custom native code:
npx expo prebuild
3

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.

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'

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:
platform :ios, '17.0'

Module Not Found Errors

If you see “Module not found” errors:
  1. Clear your package manager cache:
    # npm
    npm cache clean --force
    
    # yarn
    yarn cache clean
    
    # pnpm
    pnpm store prune
    
  2. Reinstall dependencies:
    rm -rf node_modules
    yarn install
    
  3. 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

Build docs developers (and LLMs) love