GitHub Repository
View source code and examples on GitHub
npm Package
@didit-protocol/sdk-react-native
Native SDK: This is the recommended approach for React Native and Expo apps. The SDK wraps the native iOS and Android SDKs for the best user experience, optimized camera handling, and full NFC support.
Requirements
| Requirement | Minimum Version |
|---|---|
| React Native | 0.76+ (New Architecture / TurboModules) |
| Node.js | 20+ |
| TypeScript | 5+ |
Platform Requirements
| Platform | Minimum Version | Notes |
|---|---|---|
| iOS | 13.0+ | NFC passport reading requires iOS 15.0+ |
| Android | API 23+ (6.0) | Kotlin 1.9+, Java 17+ |
Installation
Expo (Recommended)
app.json (or app.config.js):
- Android: Adds the Didit Maven repository to Gradle and packaging exclusions
- iOS: Adds the DiditSDK podspec to the Podfile
React Native CLI
iOS Setup
Add the DiditSDK pod to yourPodfile (it’s not on CocoaPods trunk):
Android Setup
Add the Didit Maven repository to your project-levelsettings.gradle:
build.gradle to avoid build conflicts:
Permissions
iOS
Add the following keys to your app’sInfo.plist:
| Permission | Info.plist Key | Description | Required |
|---|---|---|---|
| Camera | NSCameraUsageDescription | Document scanning and face verification | Yes |
| NFC | NFCReaderUsageDescription | Read NFC chips in passports/ID cards | If using NFC |
| Location | NSLocationWhenInUseUsageDescription | Geolocation for fraud prevention | Optional |
NFC Configuration
To enable NFC reading for passports and ID cards with chips:-
Add NFC Capability in Xcode:
- Select your target > Signing & Capabilities > + Capability > Near Field Communication Tag Reading
-
Add ISO7816 Identifiers to
Info.plist:
Android
The following permissions are declared in the SDK’sAndroidManifest.xml and merged automatically:
| Permission | Description | Required |
|---|---|---|
INTERNET | Network access for API communication | Yes |
ACCESS_NETWORK_STATE | Detect network availability | Yes |
CAMERA | Document scanning and face verification | Yes |
NFC | Read NFC chips in passports/ID cards | If using NFC |
android:required="false"), so your app can be installed on devices without these features.
Quick Start
Integration Methods
The SDK supports two integration methods:Method 1: Session Token (Recommended for Production)
Create a session on your backend using the Create Verification Session API, then pass the token to the SDK:- Associating sessions with your users (
vendor_data) - Setting custom metadata
- Configuring callbacks per session
Method 2: Workflow ID (Simpler Integration)
For simpler integrations, the SDK can create sessions directly using your workflow ID:Configuration
Customize the SDK behavior by passing a config object:startVerificationWithWorkflow, pass config inside options.config:
Configuration Options
| Property | Type | Default | Description |
|---|---|---|---|
languageCode | string | Device locale | ISO 639-1 language code (e.g. "en", "fr", "ar") |
fontFamily | string | System font | Custom font family name (must be registered natively) |
loggingEnabled | boolean | false | Enable SDK debug logging |
Theming & Colors: Colors, backgrounds, and intro screen settings are configured through your White Label settings in the Didit Console, not in the SDK configuration. This ensures consistent branding across all platforms.
Language Support
The SDK supports 40+ languages. If no language is specified, the SDK uses the device locale with English as fallback.Advanced Options
These options are only available withstartVerificationWithWorkflow, where the SDK creates the session on your behalf.
Contact Details (Prefill & Notifications)
Provide contact details to prefill verification forms and enable email notifications:Expected Details (Cross-Validation)
Provide expected user details for automatic cross-validation with extracted document data:Custom Metadata
Store custom JSON metadata with the session (not displayed to user):Handling Results
BothstartVerification and startVerificationWithWorkflow return a Promise<VerificationResult>. The result is a discriminated union — use the type field to determine the outcome.
Result Cases
| Case | Description |
|---|---|
completed | Verification flow completed (check session.status for result) |
cancelled | User cancelled the verification flow |
failed | An error occurred during verification |
SessionData Properties
| Property | Type | Description |
|---|---|---|
sessionId | string | Unique session identifier |
status | VerificationStatus | Approved, Pending, or Declined |
Error Types
| Error | Description |
|---|---|
sessionExpired | The session has expired |
networkError | Network connectivity issue |
cameraAccessDenied | Camera permission not granted |
notInitialized | SDK not initialized (Android only) |
apiError | API request failed |
unknown | Other error with message |