The initExecutorch function initializes the React Native ExecuTorch library by configuring a resource fetcher adapter. This is a required setup step that must be called before using any hooks or modules.
import { initExecutorch } from 'react-native-executorch';import { ExpoResourceFetcher } from '@react-native-executorch/expo-resource-fetcher';// Initialize at app startup (e.g., in App.tsx)initExecutorch({ resourceFetcher: new ExpoResourceFetcher(),});
import { initExecutorch } from 'react-native-executorch';import { BareResourceFetcher } from '@react-native-executorch/bare-resource-fetcher';// Initialize at app startup (e.g., in index.js)initExecutorch({ resourceFetcher: new BareResourceFetcher(),});
You must call initExecutorch before using any hooks or modules in the library. Failure to initialize will result in a ResourceFetcherAdapterNotInitialized error.
Call initExecutorch only once at application startup. Multiple calls will override the previous configuration.
If you attempt to use any hook or module without initializing, you’ll receive:
ResourceFetcherAdapterNotInitialized: ResourceFetcher adapter is not initialized. Please call initExecutorch({ resourceFetcher: ... }) with a valid adapter.