Installation
Prerequisites
Before installing react-native-nitro-inspire-face, you need to have react-native-nitro-modules set up in your project.
Installing the library
Install react-native-nitro-inspire-face through your preferred package manager:
- Expo
- NPM
- Yarn
- Bun
npx expo install react-native-nitro-modules react-native-nitro-inspire-face
npm install react-native-nitro-modules react-native-nitro-inspire-face
yarn add react-native-nitro-modules react-native-nitro-inspire-face
bun add react-native-nitro-modules react-native-nitro-inspire-face
Model Package Setup
This library requires model files from the InspireFace SDK to function. The models are available in different packages optimized for various use cases:
- Pikachu (Default) - Lightweight edge-side models (~15.8MB)
- Megatron - Mobile and server models (~60.2MB)
You can choose between two approaches for loading models:
Option 1: Runtime Model Loading (Recommended)
Load models at runtime by downloading them from a remote URL (e.g., CDN, GitHub Releases, or Cloudflare R2). This approach significantly reduces your app bundle size and is recommended for most use cases.
Setup:
- Host your model package on a CDN or file server
- Calculate the SHA-256 checksum of your model file
- Use the
launchWithRemoteModel()function in your app code (see Basic Usage for examples)
No build-time configuration is needed for this approach.
Option 2: Bundle Models at Build Time
Bundle the model package directly with your app. This increases your app size but ensures the model is always available offline.
Setup: Download your chosen model package from the InspireFace Releases page and follow the configuration steps below.
Project Configuration
Skip this section if you're using Runtime Model Loading (Option 1). The configuration below is only needed if you want to bundle models at build time.
- Expo
- React Native CLI
Expo Setup
- Add the plugin to your Expo config (
app.json,app.config.jsonorapp.config.js):
{
"expo": {
"plugins": [
[
"react-native-nitro-inspire-face",
{
"modelName": "Pikachu", // Optional: specify model to bundle (e.g., "Pikachu" or "Megatron")
"modelDir": "assets/models" // Optional: custom directory for model files (defaults to project root)
}
]
]
}
}
If you're using runtime model loading, you can omit the modelName property or leave the config empty:
["react-native-nitro-inspire-face"]
-
Place the model package in your project's root directory (or in the custom directory specified by
modelDir). -
Run the command to copy the model package into both the iOS and Android platforms.
npx expo prebuild
Android Setup
Place your downloaded model package (e.g., "Pikachu") in the assets directory. If the directory doesn't exist yet, create it first:
android/app/src/main/assets/
└── Pikachu
iOS Setup
- Open your project in Xcode
- Right-click on your project in the navigator
- Select "Add Files to [Your Project Name]"
- Add the model package (e.g., "Pikachu")
- In the dialog that appears:
- Ensure "Copy items if needed" is checked
- Choose your app target
- Click "Add"
- Verify the model package appears in your target's "Copy Bundle Resources" build phase
Next Steps
Now that you have installed react-native-nitro-inspire-face and set up the model package, you can start using the library in your project. Check out the Basic Usage guide to learn how to implement face detection and recognition features.