Live demos
Each card is a real page using the shipped public API — no mock-ups.
Scan a code
The built-in dialog: viewfinder, torch, ✕. Live frames go through the same one worker as everything else.
scan()
bring your own
Your video / mount point
Use your own <video> with your AbortController, or mount the built-in dialog inside a card.
scan({ video, signal })
still image
Scan a photo or file
Drop a picture, pick a file, or try a generated sample. Nothing leaves the browser.
scan({ image })
encoder
Render any symbol
All 17 symbologies, with QR EC/mask/version, PDF417 level/columns and Data Matrix sizes. Scan it back in one click.
render(code, opts)
worker
Use the worker entry
The explicit /worker entry and the auto entry inside a real module Worker, handed to barcode({ worker }).
barcode({ worker })
self-test
Round-trip every symbology
31 synthetic specimens through the exact GPU/CPU binarizer → WASM pipeline, plus SVG round-trips and render options.
31 cases
contract
Worker transports
Caller-created workers, URL workers, duplicate binding, abort + re-scan, raw-byte render round-trips.
9 checks
One import, three entries
| import | context | default |
|---|---|---|
@webreflection/barcode | auto | page → barcode(); worker → bootstrap promise |
@webreflection/barcode/main | page | barcode(options) |
@webreflection/barcode/worker | worker | bootstrap promise |
@webreflection/barcode/css | page | optional default scan UI |
import barcode from '@webreflection/barcode';
import '@webreflection/barcode/css';
const { scan, render } = barcode(); // one session, one worker
const code = await scan(); // default UI: camera + torch + ✕
if (code) {
console.log(code.symbology, code.text);
document.body.append(await render(code));
}
What it reads
2D
qrcode (v1–40, all EC levels and masks, ECI, rotation/perspective), microqr, datamatrix (square and rectangular), aztec, pdf417.
1D
ean13 / upca, ean8, upce, code39, code93, code128 / GS1-128, itf, codabar, GS1 DataBar (Omni, Limited, Stacked, Stacked Omni).
Inverted (white-on-black) codes work on both paths. A code filling a dark scene and a white-on-black code on a light page are handled by the same polarity pass.
The API in one screen
scan(options)
One complete scan. Resolves once with the best Code
(most centered first) or undefined for a graceful stop.
Modes: { into }, { video, signal } or
{ image }.
await scan(); // built-in UI
await scan({ into: '#modal' }); // mount it yourself
await scan({ video, signal }); // your <video>
await scan({ image }); // still: canvas | bitmap |
// image | SVG | Blob/File
render(result, opts)
Re-encodes the payload as a fresh SVG (class
barcode-svg). Options: module,
height, QR ec/mask/version,
PDF417 level/columns, Data Matrix
rows/cols.
await render(code);
await render(code, { ec: 'H', version: 7 });
await render(code, { rows: 12, cols: 36 });
Private by construction
The camera stream, still images and decoded payloads never leave the device. There is no analytics, no upload endpoint and no network call after the static files are fetched.
Run it locally
npm install
npm run build # → packages/web/dist
npm run build:demo # → packages/web/demo-dist
npm run serve:demo # http://<lan-ip>:8124
# phone over USB, no HTTPS needed
adb reverse tcp:5173 tcp:5173
npm run dev # http://localhost:5173/scan.html
A real iPhone needs a secure origin: npm run serve:iphone
serves the built demo over LAN HTTPS with mkcert and prints the
one-time CA trust steps.