vue-cam-barcode

Vue 3 camera barcode scanner for phones and tablets. Native BarcodeDetector when possible, zxing-wasm ponyfill otherwise.
514
Install
npm install vue-cam-barcode
Latest Version:0.2.0
Vue:3
License:MIT
Last Updated:Sep 22, 2026
Links: GitHub  ·  npm
Maintainer: hosseinmirhosseini76

vue-cam-barcode

Tiny Vue 3 barcode scanner. Camera-only (phone/tablet rear camera). Uses native BarcodeDetector when it supports the formats; otherwise the barcode-detector ponyfill (ZXing WASM).

Install

npm i vue-cam-barcode

Peer: vue@^3.3. Needs HTTPS (or localhost). WASM fallback is loaded on first scan if the browser cannot decode EAN/UPC natively (common on iPhone).

Usage

<script setup>
import { BarcodeScanner } from 'vue-cam-barcode'

function onDetect(result) {
  console.log(result.parsed.value)
}
</script>

<template>
  <BarcodeScanner multiple @detect="onDetect" @complete="onComplete" />
</template>

result.parsed.value is the barcode string. With multiple, keep scanning until Close camera; @complete receives string[] of unique parsed.values.

import { useBarcodeScanner, parseBarcode } from 'vue-cam-barcode'

Props: formats, autoStart, once, multiple, cooldownMs, confirmCount (default 3), confirmWindowMs, requireValidChecksum (default true, EAN/UPC), uniqueNearDistance (default 3 in multiple — drops blurry near-miss EANs), scanRegion, preferNative. Events: @detect, @candidate, @complete, @error, @engine.

Hold the code steady until it is confirmed on several frames. Blurry frames often invent different but checksum-valid EANs; confirmation + near-duplicate filtering drops those.

Demo

Local playground / static demo build:

pnpm dev          # https playground on :5174
pnpm build:demo   # static site → demo-dist/

Author

S.Hossein Mirhosseini

Links

License

MIT

Dev

pnpm install
pnpm test
pnpm dev          # playground on :5174 — open from your phone (HTTPS)
pnpm build        # library
pnpm build:demo   # demo site → demo-dist/

Related Packages

cam2qr

Zero-dependency TypeScript QR code scanning for the browser — independent from-s...

4,003 1
@teckel/vue-barcode-reader

Vue 3 Barcodes and QR Codes Scanner

74,948 25
@orbisk/nuxt-barcode-detection

Nuxt module for @orbisk/vue-use-barcode-detection (auto-imports, components, pol...

3,780 3
scanbot-web-sdk

Scanbot Web Document and Barcode Scanner SDK

750,225
@feugene/granularity-media

Media components for @feugene/granularity: image cropping, camera capture, code...

2,517 1

Version History

Version Released Vue License
0.2.0 ^3.3.0 MIT
0.1.1 ^3.3.0 MIT
0.1.0 ^3.3.0 MIT