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

@amrshbib/react-native-barcode-laser

v0.1.1

Published

React Native bridge for Android handheld laser/infrared barcode scanners (Sunmi L2s Pro, L3, Zebra, Honeywell, Chainway, Urovo, Generic). Broadcast Intent + Keyboard Wedge support, no camera.

Downloads

242

Readme

React Native Barcode Laser

npm downloads npm downloads License: MIT React Native

A high-performance React Native bridge for Android handheld laser/infrared barcode scanners. This package integrates directly with physical scan engines (not cameras) for enterprise PDA devices like Sunmi, Zebra, Honeywell, Chainway, and Urovo.

✨ Features

  • 🚀 Hardware Native: Zero-latency capture via native Android Broadcast Intents.
  • 📡 OEM Support: Pre-configured for Sunmi, Zebra (DataWedge), Honeywell, Newland, Chainway, and more.
  • 🏗️ Dual Mode: Supports both Broadcast Intent (API) and Keyboard Wedge modes.
  • 🎣 Power Hook: useBarcodeLaser hook with state management and promise-based one-shot scanning.
  • 🔔 Feedback Control: Native support for hardware beeps and vibrations.
  • 🛠️ Developer Friendly: Inject fake scans for testing, debounce, length filtering, and device info.
  • 📝 TypeScript First: Complete type definitions for a better development experience.

📦 Installation

npm install @amrshbib/react-native-barcode-laser
# or
yarn add @amrshbib/react-native-barcode-laser

Android Configuration

Android autolinking handles the setup. After installation, rebuild your project:

cd android && ./gradlew clean && cd ..
npx react-native run-android

Note: This package is Android-only as it targets handheld hardware scanners. iOS calls will return safe defaults (e.g., isAvailable() -> false).

🚀 Quick Start

1. Using the Hook (Recommended)

import { useBarcodeLaser } from "@amrshbib/react-native-barcode-laser";

const ScannerScreen = () => {
  const { lastScan, started, available, scan } = useBarcodeLaser({
    autoStart: true,
    onScan: (event) => {
      console.log("Scanned:", event.data);
    }
  });

  // Example of capturing a single scan programmatically
  const scanOne = async () => {
    const result = await scan();
    alert(`Captured: ${result.data}`);
  };

  if (available === false) return <Text>Hardware scanner not found</Text>;

  return (
    <View>
      <Text>Status: {started ? "Active" : "Stopped"}</Text>
      <Text>Last Barcode: {lastScan?.data}</Text>
      <Button title="One-shot Scan" onPress={scanOne} />
    </View>
  );
};

2. Imperative API

import BarcodeLaser from "@amrshbib/react-native-barcode-laser";

// Start the listener
const initScanner = async () => {
  await BarcodeLaser.configure({ 
    mode: 'broadcast',
    beepOnSuccess: true 
  });
  await BarcodeLaser.start();
  
  const sub = BarcodeLaser.addListener((event) => {
    console.log(`Scanned: ${event.data} via ${event.source}`);
  });
};

📖 API Reference

BarcodeLaser.configure(options)

Sets global configuration for the scanner hardware.

| Property | Type | Default | Description | | :--- | :--- | :--- | :--- | | mode | string | 'broadcast' | 'broadcast', 'wedge', or 'auto' | | beepOnSuccess | boolean | true | Play system beep on successful scan | | vibrateOnSuccess| boolean | false | Vibrate on successful scan | | vibrateDurationMs | number | 60 | Duration of the success vibration | | debounceMs | number | 50 | Prevents rapid-fire duplicate scans | | minLength | number | 1 | Ignore barcodes shorter than this | | maxLength | number | 0 | Ignore barcodes longer than this (0 = no limit) | | stripWhitespace | boolean | true | Trims results automatically | | actions | string[] | (Defaults) | Custom intent actions to listen for | | extras | string[] | (Defaults) | Custom intent extra keys for data |

BarcodeLaser.start() / stop()

Enables or disables the hardware listener. Returns Promise<boolean>.

BarcodeLaser.trigger() / stopTrigger()

Programmatically toggles the physical laser beam (on supported hardware).

BarcodeLaser.beep() / vibrate(ms)

Manually trigger the handheld's feedback systems.

BarcodeLaser.injectScan(data, type)

Inject a mock scan event into the listener. Great for development on emulators.

BarcodeLaser.getDeviceInfo()

Returns Promise<{ manufacturer: string, model: string, isSunmi: boolean, ... }> with detailed OEM info.

🎣 useBarcodeLaser Hook

Exposes the full power of the scanner as a React state.

| Return Key | Type | Description | | :--- | :--- | :--- | | available | boolean \| null | null while detecting, then true if hardware found | | started | boolean | Current status of the listener | | lastScan | ScanEvent | The most recently captured barcode object | | error | ScanError | Last error event | | scan() | () => Promise | Triggers laser and resolves with the next scan | | trigger() | Function | Fire the laser manually | | beep() | Function | Play system beep |

🔧 Platform Setup & OEM Config

Sunmi Devices (L2s Pro, L3, etc.)

  1. Open Scanner Settings on the device.
  2. Output Mode: Output via API (or Broadcast).
  3. Intent Action: com.sunmi.scanner.ACTION_DATA_CODE_RECEIVED.
  4. Intent Extra: data.

Zebra (DataWedge)

  1. Open DataWedge app.
  2. Select your profile (e.g., Profile0).
  3. Intent Output: Enabled.
  4. Intent Action: com.symbol.datawedge.api.RESULT_ACTION.
  5. Intent Delivery: Broadcast Intent.

🤝 Contributing & Support

If you have a specific handheld device that requires a new default intent action, please submit a PR or open an issue!

📄 License

The MIT License - Copyright (c) 2024 Amr Shbib