Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-scan-qr-code

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-scan-qr-code

A React Component for scanning QR codes from the webcam

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

React QR Code Scanner npm version License: MIT

Table of contents

Use Case

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

Compatibility

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.

Installation

You can install this library via NPM or YARN.

NPM

npm i react-qr-code-scanner

YARN

yarn add react-qr-code-scanner

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 { QrScanner } from 'react-qr-code-scanner';

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

  return (
    <>
      <QrScanner
        onsuccess={(result, error) => {
          if (!!result) {
            setData(result);
          }

          if (!!error) {
            console.info(error.message);
          }
        }}
        style={{ width: '100%' }}
      />
      <p>{data}</p>
    </>
  );
};

Component API

The QrCodeScanner component has the following props:

PropertiesTypesDefault ValueDescription
constraintsMediaTrackConstraints{ facingMode: 'user' }Specify which camera should be used (if available).
onSuccessfunctionnoneScan 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.

License

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

Keywords

FAQs

Package last updated on 21 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc