React QR Scanner Demo
SCANNED VALUE:

Scan this QR code with your camera to test. The result should show up above.

Expected value is: "Test QR Code Value"

Get Started

Install:
npm i react-qrcode-scanner
Usage:

                
        import React from 'react';
        import {QrScanner} from "react-qrcode-scanner";

        function App() {

          const handleScan = (value) => {
              console.log({value})
          }

          const handleError = (error) => {
              console.log({error})
          }

          return (
            <div className="App">
              <QrScanner
                  onScan={handleScan}
                  onError={handleError}
              />
            </div>
          );
        }
        
Prop NameTypeDefault ValueDescription
onErrorFunction(error) => console.log({error})Callback function that is called when an error occurs during scanning.
onScanFunction(value) => console.log({value})Callback function that is called when a QR code is successfully scanned.
facingModeString'environment'The facing mode of the camera. Can be set to 'environment' or 'face'.
constraintsObjectnullThe device constraints for the camera.
onLoadFunction(val: {mirrorVideo, streamLabel}) => nullCallback function that is called when the component is loaded.
flipHorizontallyBooleanfalseDetermines whether the video output should be flipped or reflected based on the facing mode.
styleObjectnullAdditional styling for the section.
classNameStringnullAdditional class names for the section wrapper.
delayNumber800The delay between each scan attempt in milliseconds.
resolutionNumber600The resolution of the canvas in pixels.
videoObject{ width: '50%', height: '85%' }Additional CSS styles for the video element.
showViewFinderBooleantrueDetermines whether to show the viewfinder.
viewFinderObject{ border: '12px solid rgba(255,255,255,0.3)', position: 'absolute', borderRadius: '5px', width: '250px', height: '250px' }Additional CSS styles for the viewfinder element.