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 🙏

© 2026 – Pkg Stats / Ryan Hefner

fast-barcode-scanner

v0.1.10

Published

A React barcode scanner component with WASM support for ZXing and Photon image processing. Includes IIFE standalone build for direct browser use.

Readme

Barcode Scanner - WebAssembly Powered

A professional barcode scanner application powered by WebAssembly with advanced image processing and multi-engine detection.

🚀 Features

  • Multi-Engine Detection: Native BarcodeDetector API + ZXing WASM
  • Advanced Image Processing: Photon WASM for enhancement (grayscale, contrast, sharpen, threshold, histogram equalization)
  • Intelligent Frame Caching: SubtleCrypto SHA-256 hashing with JS fallback
  • Adaptive Rotation: Automatic 90°/270° rotation with Photon WASM or Canvas fallback
  • Configurable FPS: Default 30 FPS, fully configurable
  • Parallel Processing: All enhancement techniques run simultaneously
  • Multiple Formats: EAN-13, EAN-8, UPC-A, UPC-E, Code128, Code39, QR, DataMatrix, and more
  • 📦 NPM Package Ready: Full build and export configuration included

📦 Building as NPM Package

This project includes complete packaging configuration to publish as a reusable npm package with Bun as the bundler!

Requirements

  • Bun - Fast JavaScript runtime and bundler (Install Bun)
    curl -fsSL https://bun.sh/install | bash

Quick Start - Build & Publish

# Install dependencies (if not already installed)
bun install

# Build the library (bundles JS + TypeScript declarations + WASM files)
bun run build:lib

# The build creates a ./dist directory with:
# - Bundled JavaScript (IIFE format for universal browser support)
# - TypeScript type definitions
# - WASM modules (zxing-wasm and photon)

# Test the package locally
npm pack
# This creates a .tgz file you can install in other projects

# Publish to npm (update package name in package.json first!)
npm publish --access public

What Gets Built

The build process using Bun:

  1. Bundles all React components and hooks into optimized IIFE format
  2. Generates TypeScript declarations for full type safety
  3. Copies WASM files from dependencies (ZXing, Photon) to dist
  4. Exposes global window.FastBarcodeScanner for direct browser use
  5. No module system required - works with simple <script> tags!

IIFE Format Benefits

The standalone build uses IIFE (Immediately Invoked Function Expression) format:

Universal Browser Support - Works in all browsers, no ES modules required ✅ Simple Script Tag Loading - No build tools or bundlers needed ✅ Global Variable Access - Available as window.FastBarcodeScannerNo Top-Level Await - Compatible with older browsers ✅ CDN-Ready - Perfect for CDN delivery (jsDelivr, unpkg)

Direct Browser Usage:

<!DOCTYPE html>
<html>
<body>
  <div id="scanner-container"></div>
  
  <!-- Load from local file or CDN -->
  <script src="./dist/standalone.js"></script>
  <!-- Or: <script src="https://cdn.jsdelivr.net/npm/fast-barcode-scanner@latest/dist/standalone.js"></script> -->
  
  <script>
    // Access via global variable
    const { BarcodePicker, ScanSettings, Symbology } = window.FastBarcodeScanner;
    
    const settings = new ScanSettings();
    settings.enableSymbologies([Symbology.QR, Symbology.EAN13]);
    
    BarcodePicker.create(document.getElementById('scanner-container'), settings)
      .then(picker => {
        picker.onDidScan((result) => {
          console.log('Scanned:', result.barcodes[0].data);
        });
        return picker.startScanning();
      });
  </script>
</body>
</html>

For more details, see IIFE_FORMAT.md.

Package Features

Once published, your package provides:

Main Hook - useBarcodeScanner hook for React ✅ React Components - CameraPreview, ResultDisplay, ScanHistoryLegacy Barcode Scanner API - Drop-in compatibility layer via LegacyBarcodeScanner namespace ✅ IIFE Format - Universal browser support via window.FastBarcodeScannerTypeScript - Full type definitions included ✅ WASM Support - ZXing and Photon WASM modules bundled ✅ CDN Ready - Works with jsdelivr, unpkg, and other CDNs

Usage After Publishing

Installation (for npm/module usage):

npm install fast-barcode-scanner
# or
bun add fast-barcode-scanner

Method 1: Direct Browser Use (IIFE - Recommended for HTML pages):

<script src="https://cdn.jsdelivr.net/npm/fast-barcode-scanner@latest/dist/standalone.js"></script>
<script>
  const { BarcodePicker, ScanSettings, Symbology } = window.FastBarcodeScanner;
  
  const settings = new ScanSettings();
  settings.enableSymbologies([Symbology.QR]);
  
  BarcodePicker.create(container, settings).then(picker => {
    picker.onDidScan((result) => console.log(result));
    picker.startScanning();
  });
</script>

Method 2: Module Import (for React/bundler projects):

import { useBarcodeScanner, CameraPreview } from 'fast-barcode-scanner';

function App() {
  const { videoRef, canvasRef, isScanning, result, startScanning } =
    useBarcodeScanner({ formats: ['EAN-13', 'QRCode'] });

  return (
    <div>
      <CameraPreview
        videoRef={videoRef}
        canvasRef={canvasRef}
        isScanning={isScanning}
        hasResult={!!result}
      />
      <button onClick={startScanning}>Start Scanning</button>
      {result && <div>Scanned: {result.text}</div>}
    </div>
  );
}

Using Legacy Barcode Scanner Compatibility:

In Browser (IIFE):

<script src="./dist/standalone.js"></script>
<script>
  const { BarcodePicker, ScanSettings, Symbology } = window.FastBarcodeScanner;

  const settings = new ScanSettings();
  settings.enableSymbologies([Symbology.EAN13]);

  BarcodePicker.create(container, settings).then(picker => {
    picker.onDidScan((result) => console.log(result));
    picker.startScanning();
  });
</script>

With Module Import:

import { LegacyBarcodeScanner } from 'fast-barcode-scanner';

const settings = new LegacyBarcodeScanner.ScanSettings();
settings.enableSymbologies([LegacyBarcodeScanner.Symbology.EAN13]);

const picker = await LegacyBarcodeScanner.BarcodePicker.create(container, settings);
picker.onDidScan((result) => console.log(result));
picker.startScanning();

🎨 Spark Application (This App)

The barcode scanner is also available as a React app in this Spark:

📦 Legacy Barcode Scanner Compatibility Layer

This project includes a compatibility layer for legacy barcode scanner libraries with a familiar API!

Quick Start with Legacy Scanner-Compatible API

import { LegacyBarcodeScanner } from '@yknx4/barcode-scanner'

const settings = new LegacyBarcodeScanner.ScanSettings()
settings.enableSymbologies([
  LegacyBarcodeScanner.Symbology.EAN13,
  LegacyBarcodeScanner.Symbology.QR
])

const picker = await LegacyBarcodeScanner.BarcodePicker.create(container, settings)
picker.onDidScan((result) => {
  console.log('Detected:', result.barcodes[0].data)
})

await picker.startScanning()

🎨 React Usage

The scanner is also available as a React hook:

import { useBarcodeScanner } from '@/hooks/use-barcode-scanner'

function App() {
  const { videoRef, canvasRef, startScanning, result } = useBarcodeScanner({
    formats: ['EAN-13', 'QR'],
    fps: 30
  })
  
  return (
    <div>
      <video ref={videoRef} />
      <canvas ref={canvasRef} />
      <button onClick={startScanning}>Start</button>
      {result && <div>{result.text}</div>}
    </div>
  )
}

🛠 Technology Stack

  • React + TypeScript: Modern UI framework
  • WebAssembly: High-performance barcode detection
    • ZXing WASM: Cross-platform decoder
    • Photon WASM: Image enhancement
  • Native APIs: BarcodeDetector API when available
  • Vite: Lightning-fast build tool
  • Tailwind CSS: Utility-first styling
  • shadcn/ui: Beautiful component library

📊 Performance

  • Frame Processing: 30 FPS default (configurable)
  • Detection Time: ~100-500ms average
  • Cache Hit Rate: 60-80% with frame caching
  • Multiple Enhancement Pipelines: 10+ parallel processing techniques

🌐 Browser Support

  • ✅ Chrome/Edge 88+ (full native support)
  • ✅ Firefox 90+ (ZXing WASM)
  • ✅ Safari 14+
  • ✅ Mobile browsers (iOS Safari, Chrome Android)

🔧 Configuration

const config = {
  formats: ['EAN-13', 'QR', 'Code128'],  // Barcode formats to detect
  fps: 30                                 // Scan rate (frames per second)
}

📄 License

The Spark Template files and resources from GitHub are licensed under the terms of the MIT license, Copyright GitHub, Inc.