{"id":42354,"library":"zbar.wasm","title":"zbar.wasm","description":"A WebAssembly build of the C/C++ ZBar barcode scanning library, providing fast and portable barcode recognition (including QRCode, EAN13, CODE128, etc.) for browsers and Node.js. Current stable version is 2.1.1. Released irregularly, maintained on GitHub. Key differentiator: leverages native ZBar performance via WebAssembly, offering a simple JavaScript API for scanning barcodes from ImageData.","status":"active","version":"2.1.1","language":"javascript","source_language":"en","source_url":"https://github.com/samsam2310/zbar.wasm","tags":["javascript","zbar","qrcode","scanner","typescript"],"install":[{"cmd":"npm install zbar.wasm","lang":"bash","label":"npm"},{"cmd":"yarn add zbar.wasm","lang":"bash","label":"yarn"},{"cmd":"pnpm add zbar.wasm","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM import recommended; CommonJS require works but may not resolve .wasm file correctly in bundlers","wrong":"const scanImageData = require('zbar.wasm').scanImageData","symbol":"scanImageData","correct":"import { scanImageData } from 'zbar.wasm'"},{"note":"Default export is not documented; use named exports like scanImageData instead","wrong":"import * as zbar from 'zbar.wasm'","symbol":"default","correct":"import zbar from 'zbar.wasm'"},{"note":"Scanner class for advanced usage; available since v2.0.0","wrong":"","symbol":"Scanner","correct":"import { Scanner } from 'zbar.wasm'"}],"quickstart":{"code":"const { createCanvas, loadImage } = require('canvas');\nconst { scanImageData } = require('zbar.wasm');\n\nconst getImageData = async (src) => {\n  const img = await loadImage(src);\n  const canvas = createCanvas(img.width, img.height);\n  const ctx = canvas.getContext('2d');\n  ctx.drawImage(img, 0, 0);\n  return ctx.getImageData(0, 0, img.width, img.height);\n};\n\nconst url = 'https://raw.githubusercontent.com/zbar-wasm/demo/master/node/test.png';\nconst main = async () => {\n  const img = await getImageData(url);\n  const res = await scanImageData(img);\n  console.log(res[0].typeName);\n  console.log(res[0].decode());\n};\nmain().catch(console.error);","lang":"javascript","description":"Scans a barcode from an image URL using Node.js canvas and prints type and decoded data."},"warnings":[{"fix":"Add rule for zbar.wasm.bin: { test: /\\.bin$/, use: 'file-loader' }","message":"Webpack requires file-loader for .wasm file (zbar.wasm.bin) - do not use default wasm extension handling","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Serve .wasm files with Content-Type: application/wasm","message":"Browser environment needs to load the .wasm file asynchronously; ensure MIME type is correct on server (application/wasm)","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Replace import zbar from 'zbar.wasm' with import { scanImageData } from 'zbar.wasm'","message":"Version 2.0.0 changed the API from default export to named exports","severity":"breaking","affected_versions":"<2.0.0"}],"env_vars":null,"search_vec":"'2.1.1':31 'api':49 'barcod':9,16,52 'browser':24 'build':4 'c/c':7 'code128':21 'current':27 'differenti':38 'ean13':20 'etc':22 'fast':13 'github':36 'imagedata':54 'includ':18 'irregular':33 'javascript':48,55 'key':37 'leverag':39 'librari':11 'maintain':34 'nativ':40 'node.js':26 'offer':45 'perform':42 'portabl':15 'provid':12 'qrcode':19,57 'recognit':17 'releas':32 'scan':10,51 'scanner':58 'simpl':47 'stabl':28 'typescript':59 'version':29 'via':43 'webassembl':3,44 'zbar':8,41,56 'zbar.wasm':1","created_at":"2026-06-04T18:56:51.051019+00:00","updated_at":"2026-06-04T18:56:51.051019+00:00","problems":[{"fix":"Add file-loader rule for /zbar\\.wasm\\.bin$/ in webpack config","cause":"Webpack not configured to handle .bin file extension","error":"Module not found: Error: Can't resolve 'zbar.wasm.bin'"},{"fix":"Ensure server sends application/wasm for .wasm files","cause":"Browser can't load .wasm file due to MIME type mismatch","error":"TypeError: Failed to fetch dynamically imported module"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/samsam2310/zbar.wasm#readme","github":"https://github.com/samsam2310/zbar.wasm","docs":null,"changelog":null,"pypi":null,"npm":"zbar.wasm","openapi_spec":null,"status_page":null,"smithery":null,"categories":["ai-ml","testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}