npm i react-qr-reader


React component for reading QR codes from webcam.

by react-qr-reader

3.0.0-beta-1 (see all)License:MITTypeScript:Built-In
npm i react-qr-reader

React QR Reader npm version License: MIT Known Vulnerabilities

🚀 React QR Reader component. Check out the demo.

Table of contents

Use Case

You need a component for Scanning QR codes from a web browser based app.


This component has been tested in the following browsers:

  • Chrome Mac OS & Android
  • Firefox Mac OS & Android
  • Safari Mac OS & IOS

Since this library does internal use of hooks you need React >= 16.8.0.


You can install this library via NPM or YARN.


npm i react-qr-reader


yarn add react-qr-reader

Example Usage

After reading and performing the previous steps, you should be able to import the library and use it like in this example:

import React, { useState } from 'react';
import { QrReader } from 'react-qr-reader';

const Test = (props) => {
  const [data, setData] = useState('No result');

  return (
        onResult={(result, error) => {
          if (!!result) {

          if (!!error) {
        style={{ width: '100%' }}

Component API

The QrReader component has the following props:

PropertiesTypesDefault ValueDescription
constraintsMediaTrackConstraints{ facingMode: 'user' }Specify which camera should be used (if available).
onResultfunctionnoneScan event handler
videoIdstringvideoThe ID for the video element
scanDelaynumber500The scan period for the QR hook
ViewFindercomponentnoneViewFinder component to rendering over the video element
classNamestringnoneClassName for the container element.
containerStyleobjectnoneStyle object for the container element.
videoContainerStyleobjectnoneStyle object for the video container element.
videoStyleobjectnoneStyle object for the video element.

Browser Support

If you need to support older browsers, checkout this guide in how to make it compatible with legacy ones


Please, open an issue following one of the issues templates. We will do our best to fix them.


If you want to contribute to this project see contributing for more information.


Distributed under the MIT license. See LICENSE for more information.