Skip to content

React components

biometry-react-components provides the capture half of an integration: camera and microphone components that handle permissions, countdowns, recording windows and the challenge phrase, then hand you ordinary File objects.

It has no HTTP layer. Components capture media and emit files; you send those files with the Web SDK or your own backend. That separation is deliberate — your API token never has to reach the browser.

Installation

npm install biometry-react-components

Components

ComponentPurpose
FaceCaptureStill photo of a face
DocScanPhoto of an identity document
FaceRecorderVideo with spoken challenge digits, for verification
VoiceRecorderVoice enrollment across several takes
import { FaceRecorder } from 'biometry-react-components';
<FaceRecorder
challengeDigits={challenge} // issued by your backend, e.g. "48719352"
recordingSeconds={10}
onConfirmRecording={({ file }) => upload(file)}
/>

Upload file. The voice is extracted server-side from the same video that passed the liveness check, so there is no separate audio file to send — and a separately supplied one is not accepted, because the voice check is bound to the verified video.

Use a challenge from your backend

The digits the user reads should be a challenge your backend issues: we recommend 8 distinct digits from 1–9, from a secure random source, stored against the user’s login attempt, valid for at most 5 minutes and used once. Pass it to FaceRecorder as challengeDigits, then have your backend send its own stored copy as phrase. Record for about 10 seconds (recordingSeconds={10}). See Liveness challenge for the rules, why 8 digits, and Node and Go examples.

challengeDigitsBehaviour
"48719352" or [4, 8, 7, 1, 9, 3, 5, 2] (3.0.0+ for the string form)Shown and emitted exactly as given.
Fewer than 7 or more than 12 digits, anything other than 0–9, spaces, an empty string or arrayThrows during render. It is never swapped for other digits. Wrap the recorder in an error boundary if the value isn’t trusted.
null or left outDeprecated: the component generates digits in the browser and logs a one-time console.warn per component instance. Existing apps keep working, with no replay protection.

Render the recorder once the challenge has arrived, so the user never starts with generated digits. A new value is applied only while the recorder is idle.

The payload’s phrase (the digits in words) and challenge (the digits as shown, 3.0.0+) are for display and logging. Don’t send them as the phrase your backend checks.

A phrase chosen or returned by the device doesn’t stop replays: someone who controls the device, or calls your backend directly, can pair a pre-recorded video of the user with whatever digits that video happens to say, and every lip-reading and voice check agrees. Only digits your backend chose, kept and compares against prove the video was recorded just now.

Each component reports twice: once when media is captured, and again once the person has confirmed it. Use the confirmed callback for anything you upload — the first fires before the user has had a chance to retake.

Hooks

useRecorder, usePermissions and useAudioPermissions back the components and are exported for building your own capture UI.

Full component and hook reference: the biometry-react-components README (npm).