1.2.4 • Published 1 year ago

react-qrcode-scanner v1.2.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Introduction

A React component that provides a simple and efficient way to read QR codes from a web or mobile camera. This lightweight component utilizes HTML canvas to capture images and leverages the jsQR library to detect QR codes within the image data. NOTE: HTTPS is required to use camera on mobile devices. However, you can test over localhost on your computer

DEMO

Install

npm i react-qrcode-scanner

Example

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>
  );
}

export default App;

Props

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.
aspectRatiostring'16:9'Aspect ratio of the video frame. Default is landscape. Change to '3:4' for portrait
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.

License

This project is licensed under the MIT License.

1.2.0

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.1.7

1 year ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.1.6

2 years ago

1.0.7

2 years ago

1.1.5

2 years ago

1.0.6

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago