0.1.0 • Published 2 years ago

@fabiendeborde/react-simple-qr-scanner v0.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

React Simple QR Scanner

GitHub release Size GitHub license

A simple React wrapper around browser native BarcodeDetector API.

Compatibility

⚠️ Support is really not good at the moment, but enough for my use case.
If I have the time I may try to use the canvas method to have a fallback when BarcodeDetector is not available.
You can check here the global support of this API: caniuse

Setup

npm i @fabiendeborde/react-simple-qr-scanner
yarn add  @fabiendeborde/react-simple-qr-scanner

Props

nametypedefaultdescription
onScan -required-(decoded: string) => voidnoneScan event handler (will be called with the decoded string)
containerStyleReact.CSSPropertiesempty objectA style object for the video wrapper element
videoStyleReact.CSSPropertiesempty objectA style object for the video element
withTorchbooleanfalseToggle the camera torch (light)
focusMode'manual', 'single-shot', 'continuous''continuous'Set the camera focus mode
facingMode'environment', 'user'noneSpecify which camera should be used (if available)

Usage

<QrScanner
  onScan={(decoded) => console.log(decoded)}
  facingMode="environment"
  withTorch={false}
  focusMode="continuous"
/>

You can also find a really basic example in the example folder of this repository.

Issues

If you find a bug or would like to see some new features in this library, feel free to open an issue here.
I'll try my best to look at it and answer you quickly.

License

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

0.1.0

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago