GithubHelp home page GithubHelp logo

jodusnodus / react-qr-reader Goto Github PK

View Code? Open in Web Editor NEW
1.1K 1.1K 402.0 3.9 MB

React component for reading QR codes from webcam.

Home Page: https://jodusnodus.github.io/react-qr-reader

License: MIT License

JavaScript 20.40% TypeScript 79.60%
javascript qr-code qrcode react reactjs webcam webrtc

react-qr-reader's Introduction

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.

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-reader

YARN

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 (
    <>
      <QrReader
        onResult={(result, error) => {
          if (!!result) {
            setData(result?.text);
          }

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

Component API

The QrReader component has the following props:

Properties Types Default Value Description
constraints MediaTrackConstraints { facingMode: 'user' } Specify which camera should be used (if available).
onResult function none Scan event handler
videoId string video The ID for the video element
scanDelay number 500 The scan period for the QR hook
ViewFinder component none ViewFinder component to rendering over the video element
className string none ClassName for the container element.
containerStyle object none Style object for the container element.
videoContainerStyle object none Style object for the video container element.
videoStyle object none Style object for the video element.

Maintainers

Browser Support

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

Issues

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

Contributing

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

License

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.