npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@plugnotes/react-qr-scanner

v1.0.5

Published

A library to scan qr codes in react.

Downloads

36

Readme

Features

  • Scan codes using a smartphone camera or webcam.

Install

yarn add @plugnotes/react-qr-scanner

npm install @plugnotes/react-qr-scanner

Usage

import { Scanner } from '@plugnotes/react-qr-scanner';

const App = () => {
    return (
        <Scanner
            onResult={(text, result) => console.log(text, result)}
            onError={(error) => console.log(error?.message)}
        />
    );
}
  • You can also import useContinuousScanner hook and implement your own UI.
  • There is also a hook to get the available devices useDeviceList.

Supported Formats

  • This library uses the zxing-js to decode the scanned codes.

| 1D product | 1D industrial | 2D | |------------|---------------|-------------| | UPC-A | Code 39 | QR Code | | UPC-E | Code 93 | Data Matrix | | EAN-8 | Code 128 | Aztec | | EAN-13 | Codabar | PDF 417 | | | ITF | | | | RSS-14 | | | | RSS-Expanded | |

Limitations

  • Due to browser implementations the camera can only be accessed over https or localhost.
  • Beep sound in iOS will only work after user interaction.
  • Server side rendering won't work so only require the component when rendering in a browser environment.

API

| Property | Type | Description | Required | |------------|------------------------------------------|--------------------------------------------------------------------|----------| | onResult | (text: string, result: Result) => void | Callback function that is called with the scanned text and result. | Yes | | onError | (error: Error) => void | Optional callback function that is called when an error occurs. | No | | enabled | boolean | Optional flag to enable or disable the scanner. | No | | styles | IScannerStyles | Optional styles to apply to the scanner and its components. | No | | options | IScannerOptions | Optional configuration options for the browser scanner. | No | | components | IScannerComponents | Optional components to include or exclude in the scanner. | No |

IUseContinuousScannerReturn Interface

| Property | Type | Description | |--------------------|------------------------------------------------|--------------------------------------------------------------------------| | ref | RefObject<HTMLVideoElement> | A reference to the video element used for scanning. | | startScanning | () => void | A function to initiate the scanning process. | | stopScanning | () => void | A function to stop the scanning process. | | loading | boolean | Indicates whether the scanner is in the process of initializing. | | scanning | boolean | Indicates whether the scanner is currently active and scanning. | | switchTorch | (value: boolean) => void | undefined | An optional function to toggle the device's torch (flashlight) feature. | | getSettings | () => MediaTrackSettings \| undefined | An optional function to get the current settings of the media track. |

Error Interface

| Property | Type | Description | |----------|----------|------------------------------------| | name | string | The name of the error. | | message | string | The error message. | | stack | string | Optional stack trace of the error. |

IScannerStyles Interface

| Property | Type | Description | Required | |--------------|-----------------|--------------------------------------------|----------| | container | CSSProperties | Optional styles for the scanner container. | No | | video | CSSProperties | Optional styles for the video element. | No | | finderBorder | number | Optional border size for the finder. | No |

IScannerOptions Interface

| Property | Type | Description | Required | Default | |--------------------------|------------------------------------------------------------------------------------------------------------|------------------------------------------------|----------|-------------| | deviceId | string | Optional ID of the device to use for scanning. | No | undefined | | hints | Map<DecodeHintType, any> | Optional hints to fine-tune scanning. | No | undefined | | constraints | DecodeHintType | Optional constraints for the media track. | No | {...} | | delayBetweenScanSuccess | number | Optional delay between successful scans. | No | 500 | | delayBetweenScanAttempts | number | Optional delay between scan attempts. | No | 500 | | tryPlayVideoTimeout | number | Optional timeout for trying to play the video. | No | 500 |

IScannerComponents Interface

| Property | Type | Description | Required | Default | |----------|-----------|--------------------------------------------|----------|---------| | audio | boolean | Optional inclusion of an audio component. | No | true | | torch | boolean | Optional inclusion of a torch component. | No | true | | count | boolean | Optional inclusion of a count component. | No | false | | onOff | boolean | Optional inclusion of an on/off component. | No | false | | tracker | boolean | Optional inclusion of a tracker component. | No | false |