Authenticate users with Face ID, Touch ID, or fingerprint
Tags: faceid touchid fingerprint authentication security
The useBiometrics composable provides biometric authentication capabilities including Face ID on iOS, Touch ID, and fingerprint on Android. It checks device availability, handles authentication prompts, and returns detailed results.
Import
<script>
import { useBiometrics } from '@classic-homes/native/svelte';
</script>// React
import { useBiometrics } from '@classic-homes/native/react';Basic Usage
<script lang="ts">
import { useBiometrics } from '@classic-homes/native/svelte';
const bio = useBiometrics();
async function handleSecureAction() {
const result = await bio.authenticate({ reason: 'Confirm your identity' });
if (result.verified) {
console.log('Authentication successful!');
}
}
</script>
{#if bio.isAvailable === false}
<p>Biometric authentication not available</p>
{:else}
<button onclick={handleSecureAction} disabled={bio.isLoading}>
{bio.isLoading ? 'Authenticating...' : 'Authenticate'}
</button>
{/if}API Reference
| Property | Type | Description |
|---|---|---|
isAvailable |
boolean | null |
Whether biometrics are available on device |
availability |
BiometricAvailability | null |
Detailed availability info including biometry type |
isLoading |
boolean |
Whether an operation is in progress |
error |
Error | null |
Current error if any |
checkAvailability |
() => Promise<BiometricAvailability> |
Check biometric availability |
authenticate |
(options?) => Promise<BiometricResult> |
Prompt for biometric authentication |
Accessibility
- Works with screen readers and assistive technologies
- Provides loading and error states for accessible status updates
- Keyboard accessible controls
Related Features
- Secure Storage - Encrypted key-value storage for sensitive data