Socket
Book a DemoInstallSign in
Socket

use-barcode-scanner-hooks

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

use-barcode-scanner-hooks

A set of React hooks for using a webcam as a barcode scanner.

0.1.0-alpha
unpublished
latest
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

@use-barcode-scanner/hooks

A set of React hooks for using a webcam as a barcode scanner.

Created as part of a project for making a UPC reader for board games, the scanner is not 100% reliable with modern smartphones. The presence of multiple cameras and the inability to easily choose the correct camera forces several compromises.

Barcode Detection

The built-in BarcodeDetector API is used when available. When it is not available, the @undecaf/barcode-detector-polyfill is used instead.

Usage

Reference the Storybook stories for an example of implementation, as well as the companion package @use-barcode-scanner/components.

API

The primary hook useBarcodeScanner should have a relatively self-documenting API, but here are the available options:

  • zoom: an integer providing the amount of zoom to apply, defaults to 1
  • onDevices: a callback function to execute when the list of devices is available. This can be useful if you want to allow the user to select a device
  • onScan: a callback function to execute when the scanner detects a barcode. Will contain the logic to interface with your code.
  • shouldPlay: determines whether or not the video element will automatically begin playing after permission to use the camera is granted. When set to false you will need to manually start the scanner's video element playing. Defaults to true.

There are many lower level hooks used by the primary hook which can also be explored separately.

FAQs

Package last updated on 07 Mar 2025

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.