@useqr/core
v1.0.1
Published
UseQR core engine: QR matrix, styled SVG renderer, typed payload builders, decode-verify loop. MIT, zero-tracking, works in browser and Node.
Maintainers
Readme
@useqr/core
The engine behind UseQR: QR matrix generation, a styled SVG renderer, 30+ typed payload builders, and a decode-verify loop that proves a design still scans.
MIT. Two runtime dependencies. No network calls, no telemetry, no account. Works in browsers, Node 18+, Bun, Deno, and edge runtimes.
npm i @useqr/coreGenerate
import { generateSvg } from "@useqr/core";
const { svg } = generateSvg({
data: "https://example.com",
moduleStyle: "rounded",
eyeFrameStyle: "leaf",
foreground: {
type: "linear",
rotation: 45,
stops: [
{ offset: 0, color: "#312e81" },
{ offset: 1, color: "#1e3a8a" },
],
},
label: { text: "SCAN ME" },
});Eight module shapes, five eye styles (with per-corner overrides), solid/linear/radial paints, logo embedding with automatic error-correction bump, labels, and transparent backgrounds.
Typed payloads
Builders escape and validate for you, and throw a PayloadError carrying a fix string you can
show a user — or hand to an agent — verbatim.
import { buildWifi, buildUpi, PayloadError } from "@useqr/core";
buildWifi({ ssid: "CafeGuest", password: "espresso", security: "WPA" });
// "WIFI:T:WPA;S:CafeGuest;P:espresso;;"
try {
buildUpi({ vpa: "not-an-id", payeeName: "Shop" });
} catch (error) {
if (error instanceof PayloadError) console.log(error.field, error.fix);
}URL · text · email · phone · SMS · WiFi · vCard · MeCard · WhatsApp · Telegram · social hub ·
calendar event · geo · app download · UPI · PayPal · Bitcoin · Litecoin · Bitcoin Cash · Dogecoin ·
Dash · any BIP-21 chain · Ethereum · PIX · EPC/SEPA · Google review · menu · feedback · coupon ·
PDF link · JSON · Base64 · SSH/Git — plus applyUtm for campaign-tagged links.
Verify that it actually scans
The verify loop renders, rasterizes, and decodes with a real decoder (zxing), then compares against your input. Rasterization is injected because it differs per environment:
import { verifyQr } from "@useqr/core";
import { Resvg } from "@resvg/resvg-js";
const report = await verifyQr(
{ data: "hello", renderOptions: { foreground: "#cccccc" } },
(svg, width) =>
new Uint8Array(new Resvg(svg, { fitTo: { mode: "width", value: width } }).render().asPng()),
);
// { scannable, decoded, matchesInput, version, ecLevel, contrast, issues }In a browser, pass a canvas-based rasterizer instead. zxing-wasm is imported dynamically inside
verifyQr, so applications that only generate never download the wasm.
Print and cutting output
generateSvg({ data: "https://example.com", profile: "tiny" });profile: "tiny" emits SVG Tiny 1.2 — no clip paths, no ARIA attributes, no properties outside
the Tiny set — which is what Illustrator, print-shop RIPs, and cutting software expect.
Notes
- ESM only. From CommonJS, use
await import("@useqr/core"). - Semver contract. Everything exported from the package root is public API; breaking changes to it mean a major version. Internal modules are not importable by subpath.
- Rendering is deterministic — the same input always produces byte-identical SVG, which is what lets UseQR's hosted API cache forever.
Related
- Hosted tools, keyless REST API, and MCP server: https://useqr.app
- Source and issues: https://github.com/rajkaria/useqr
