1. Install
The package works with any bundler that understands ES modules: Vite, webpack 5, esbuild, Angular, Next.js.
npm install @trakwind/scanner@trakwind/scanner runs the TRAKWIND Scan engine in WebAssembly on its own worker thread. The camera preview stays smooth, it works offline, and no frame leaves the device.
The package works with any bundler that understands ES modules: Vite, webpack 5, esbuild, Angular, Next.js.
npm install @trakwind/scannerScanning needs a licence key that names the domain your page runs on, localhost included. The free 30-day trial key names localhost, 127.0.0.1 and your own domains, so you can build and show it before you buy.
*.example.com in a key covers every subdomain and example.com itself. Paid licences come with a separate development key for localhost, so the key in your live site never names it.
Give it a <video> element. It starts the back camera, scans on a worker and calls you with what it finds.
import { TrakwindScanner } from '@trakwind/scanner';
const scanner = await TrakwindScanner.create({ licenseKey: 'TW1-...' });
const session = await scanner.scanVideo(document.querySelector('video'), {
onResult(results, { ms }) {
for (const r of results) console.log(r.format, r.text, `${ms.toFixed(0)} ms`);
},
});
// later
session.stop();
scanner.destroy();Each result has text, format, extension (the EAN/UPC add-on) and line, a line through the code in video pixels for drawing a highlight.
Running your own camera stream? Pass camera: false and scanVideo reads the <video> as it is.
Photos, uploads and screenshots go through scanImage. It takes a Blob or File, an <img>, a canvas or an ImageBitmap.
const { results } = await scanner.scanImage(fileInput.files[0]);Left out, the engine reads its default set. Naming only the formats you expect makes every frame faster.
await TrakwindScanner.create({ licenseKey, formats: ['EAN_13', 'QR_CODE'] });It reads EAN/UPC, Code 128 / GS1-128, Code 39, Code 93, Codabar, ITF, GS1 DataBar, QR Code, Micro QR, rMQR, Data Matrix, PDF417, MicroPDF417, Aztec, MaxiCode, DotCode and the postal 4-state codes.
The key is checked inside the engine, offline, once: no licence server, nothing to call home. If it does not cover the page, scanner.licence says why and scanning throws a LicenceError.
if (!scanner.licence.allowed) console.warn(scanner.licence.reason);
// e.g. "domain shop.example.com is not in licence TW-2026-0001 (Example Ltd)"A key covers every engine version released up to its updates date, for ever. Renewing brings the newer versions.
The worker is loaded with new URL('./worker.js', import.meta.url), which Vite, webpack 5 and esbuild understand. If yours does not, serve the package's src/ and dist/ folders yourself and pass workerUrl.
Browsers allow the camera only on https or localhost. Your server must send .wasm files as application/wasm.
createScanner() runs the engine on the calling thread, for a web worker you manage yourself; see src/index.d.ts in the package. It needs a page: the licence is checked against the page's domain, so it does not scan in Node.js or other server-side runtimes.
await TrakwindScanner.create({ licenseKey, workerUrl: '/trakwind/src/worker.js' });The same engine ships as an Android library (AAR) with a small Java API that reads fine from Kotlin: about 1.3 MB on arm64-v8a, 16 KB page aligned, no Kotlin runtime pulled in. Android licences name the package and its signing certificate. Ask for the AAR with your trial key.
Tell us your domains or app, and we reply within one working day. One yearly price per domain or app, unlimited scans.