Skip to content

@capgo/capacitor-native-biometric

Secure credential storage and biometric-gated access for Android and iOS.

Native Biometric is a secure credential vault for iOS and Android. It stores credentials in the native Keychain or Keystore and can require biometric authentication before sensitive values are returned. It is a direct replacement for Ionic Identity Vault credential-vault flows; your app keeps control of timeout, lifecycle, privacy-screen, and custom-passcode policies.

  • setCredentials and getCredentials - Securely store and retrieve credentials for a given server.
  • getSecureCredentials - Read credentials only after a native biometric check.
  • isCredentialsSaved and deleteCredentials - Build onboarding, locked-state, and logout flows.
  • isAvailable and verifyIdentity - Check authentication availability and prompt the user when needed.
MethodDescription
isAvailableChecks if biometric authentication hardware is available.
addListenerAdds a listener that is called when the app resumes from background. This is useful to detect if biometry availability has changed while the app was in the background (e.g., user enrolled/unenrolled biometrics).
verifyIdentityPrompts the user to authenticate with biometrics.
getCredentialsGets the stored credentials for a given server.
setCredentialsStores the given credentials for a given server.
deleteCredentialsDeletes the stored credentials for a given server.
getSecureCredentialsGets the stored credentials for a given server, requiring biometric authentication. Credentials must have been stored with accessControl set to BIOMETRY_CURRENT_SET or BIOMETRY_ANY.
isCredentialsSavedChecks if credentials are already saved for a given server.
getPluginVersionGet the native Capacitor plugin version.

Use these values when handling biometricError results from authenticate.

ValueCodePlatformMeaning
UNKNOWN_ERROR0Android, iOSUnknown error occurred.
BIOMETRICS_UNAVAILABLE1Android, iOSBiometrics are unavailable because hardware is missing or unavailable.
USER_LOCKOUT2Android, iOSUser is locked out after too many failed attempts.
BIOMETRICS_NOT_ENROLLED3Android, iOSNo biometrics are enrolled on the device.
USER_TEMPORARY_LOCKOUT4AndroidUser is temporarily locked out, typically for 30 seconds.
AUTHENTICATION_FAILED10Android, iOSAuthentication failed.
APP_CANCEL11iOSApp canceled the authentication flow.
INVALID_CONTEXT12iOSAuthentication context is invalid.
NOT_INTERACTIVE13iOSAuthentication was not interactive.
PASSCODE_NOT_SET14Android, iOSDevice passcode, PIN, or fallback credential is not set.
SYSTEM_CANCEL15Android, iOSSystem canceled authentication, for example after screen lock.
USER_CANCEL16Android, iOSUser canceled authentication.
USER_FALLBACK17Android, iOSUser chose fallback authentication.

This reference is synced from src/definitions.ts in capacitor-native-biometric.

Keep going from @capgo/capacitor-native-biometric

Section titled “Keep going from @capgo/capacitor-native-biometric”

If you are using @capgo/capacitor-native-biometric to plan authentication and account flows, connect it with Using @capgo/capacitor-native-biometric for the native capability in Using @capgo/capacitor-native-biometric, @capgo/capacitor-social-login for the implementation detail in @capgo/capacitor-social-login, @capgo/capacitor-passkey for the implementation detail in @capgo/capacitor-passkey, Two-factor authentication for the implementation detail in Two-factor authentication, and SSO (Enterprise) for the implementation detail in SSO (Enterprise).