<video> element and fires onScan only after the same value is confirmed across multiple frames. Both react-webcam and the barcode-detector polyfill are pre-installed.
The scanner component
Using it
onScan receives (value, format). Conditionally render the scanner so it unmounts and releases the camera once a scan lands. For back-to-back scanning, remount after each hit with a changing key to reset confirmation state.
Why the defensive bits matter
- Multi-frame confirmation (
confirmations, default 2) is the biggest defense against misreads. Bump to 3 for high-stakes scans. - Check-digit validation rejects single-character misreads on EAN-13 / EAN-8 / UPC-A for free.
- Detect on the
<video>element. ~10× faster than screenshotting to base64, no JPEG artifacts. requestAnimationFrame+ busy lock, notsetInterval. Scans at frame rate without overlapping calls.- HD constraints (
1920×1080). The 640×480 default can’t decode a retail barcode at arm’s length. - Restrict
formatsto what the app reads. Fewer formats, fewer false positives.