DEV Community

Building Bakodo: High-Performance Browser-Based Barcode & QR Code Engine with Astro, bwip-js, and zxing-wasm

Barcodes and QR codes are ubiquitous across logistics, retail, warehousing, and event ticketing. However, most online generators either require server-side rendering roundtrips, impose strict rate limits, or plaster invasive ads over the interface.

When engineering bakodo.jp, our goal was simple: create a completely free, 100% client-side barcode suite capable of rendering 111 barcode formats (including JAN/EAN/UPC/ISBN, Code128, Data Matrix, PDF417), generating custom QR codes, handling thermal label printing (ZPL/TSPL/EPL2), and scanning codes directly from device cameras - all running locally in the browser with zero data leakage.

In this deep dive, let us explore how we combined Astro, bwip-js, zxing-wasm, and Cloudflare Workers to achieve instantaneous rendering with strict privacy.

1. 100% Client-Side Barcode Generation with bwip-js

Transmitting inventory or product data to third-party APIs introduces security and latency bottlenecks. By packaging bwip-js (Barcode Writer in Pure JavaScript) into web workers, bakodo.jp computes linear and 2D matrix symbologies purely on the client CPU.

Because everything is calculated on-canvas or exported directly to vector SVG, users can batch-render thousands of SKU labels in seconds without sending a single byte over the wire.

2. Low-Latency Camera Scanning via WebAssembly (zxing-wasm)

Real-time browser barcode scanning has historically suffered from sluggish frame rates. Traditional pure JavaScript ports struggle when decoding dense 2D matrices or damaged codes from high-resolution mobile camera feeds.

We integrated zxing-wasm - compiling the battle-tested C++ ZXing-C++ library to WebAssembly with SIMD acceleration. With a lightweight requestAnimationFrame loop, the WebAssembly module scans live video streams at 60 FPS while keeping thread utilization minimal.

3. Direct Thermal Printing: ZPL, TSPL, and EPL2 Support

Industrial operations depend heavily on dedicated thermal barcode printers (Zebra, TSC, Citizen, etc.). Rendering high-resolution bitmaps and sending them via the standard OS print dialog often results in fuzzy anti-aliased barcodes that scanners fail to read.

bakodo.jp solves this by generating native printer command languages:

  • ZPL (Zebra Programming Language): Generates precise coordinate vectors for Zebra thermal heads.
  • TSPL & EPL2: Ensures broad compatibility with low-cost desktop label printers.
  • Direct WebUSB / Web Serial / Network Raw Socket: Enables sending raw printer byte streams directly to connected thermal hardware without installing vendor drivers.

4. Architecture: Astro + Cloudflare Pages & Workers

For the frontend delivery, we leveraged Astro:

  • Zero-JS Static Shell: Fast initial paint with sub-50ms TTFB worldwide via Cloudflare edge network.
  • Island Hydration: Heavy engines (the QR studio canvas, camera scanner, and label designer) are lazy-loaded as discrete islands only when opened by the user.
  • Cloudflare Workers: Manages lightweight edge routing, PWA manifest caching, and header security policies.

Conclusion & Try It Live

Whether you need to generate GS1 compliance barcodes, design custom styled QR codes, or output raw ZPL label scripts for warehouse packing slips, test out the tools at bakodo.jp. Everything runs right inside your browser!

Read on DEV Community ↗ ← Back to News

Comments

No comments yet. Start the discussion.