expo-local-authentication
Version: 55.0.6 Provides an API for Face ID and Touch ID (iOS) or the Fingerprint API (Android) to authenticate the user with a face or fingerprint scan.Installation
Usage
API Reference
Methods
() => Promise<boolean>
Checks if device has biometric authentication hardware
() => Promise<boolean>
Checks if user has enrolled biometric records
(options?: LocalAuthenticationOptions) => Promise<LocalAuthenticationResult>
Authenticates user with biometricsOptions:
promptMessage: Message shown in authentication dialogfallbackLabel: iOS fallback button textcancelLabel: Android cancel button textdisableDeviceFallback: Disable device PIN fallbackrequireConfirmation: Require explicit user confirmation (Android)
() => Promise<AuthenticationType[]>
Gets supported authentication typesReturns array of:
FINGERPRINT, FACIAL_RECOGNITION, IRIS() => Promise<SecurityLevel>
Gets security level of enrolled authenticationReturns:
NONE, SECRET, BIOMETRIC() => void
Cancels authentication prompt (Android only)
Types
LocalAuthenticationResult
boolean
Whether authentication was successful
string | undefined
Error message if authentication failed
string | undefined
Warning message
LocalAuthenticationOptions
string
Message displayed in authentication dialog
string
iOS: Text for fallback button
string
Android: Text for cancel button
boolean
Disable device PIN/pattern fallback. Default:
falseboolean
Android: Require explicit confirmation after biometric scan. Default:
trueEnums
Examples
Basic Authentication
Check Capability
Determine Authentication Type
Protect Sensitive Action
With SecureStore Integration
Complete Example
Platform Support
Permissions
iOS
Add toapp.json:
Android
Permissions automatically added:USE_BIOMETRIC(Android 9+)USE_FINGERPRINT(Android 6-8)
Best Practices
- Check Availability: Always check hardware and enrollment before authenticating
- Graceful Fallback: Provide alternative authentication if biometrics fail
- Clear Prompts: Use descriptive
promptMessageexplaining why auth is needed - Error Handling: Handle all authentication errors gracefully
- User Choice: Don’t force biometric auth; offer alternatives
Common Error Codes
user_cancel: User canceled authenticationsystem_cancel: System canceled (e.g., app backgrounded)authentication_failed: Biometric scan failedpasscode_not_set: Device passcode not setnot_available: Biometric authentication not available