QR Anvil
QR Anvil is live at qr-anvil.com. The source code is in a public repo on GitHub (source-available, PolyForm Noncommercial license).
QR Anvil is a free QR code generator with two modes. Direct codes encode your data straight into the QR image — they work offline, with nothing in between. Tracked codes redirect through a short URL first, so every scan is logged with analytics and the destination stays editable after the code is printed.
The practical upshot: print a tracked QR on a flyer today, and you can change where it points tomorrow — and see how many people scanned it, from where, on what device.
Features
- Two code modes — Direct (encoded, offline-friendly) and Tracked (redirect + scan analytics).
- Scan analytics for tracked codes — device, OS, browser, and geo captured server-side; destination editable after the code is printed.
- Eight QR types — URL, Wi-Fi, vCard, Email, SMS, WhatsApp, PDF, and plain text.
- Three download formats — PNG, SVG, and PDF, all generated in the browser.
-
Styled QR rendering in the browser via
qr-code-styling(canvas / SVG), with an optional centre logo that is validated and resized. -
QR scanner — a page that reads QR codes from the camera or from an uploaded image (
@zxing/browser). - Accounts via Clerk authentication with webhook-based user sync. URL codes and PNG downloads need no account; tracked codes and SVG / PDF downloads need a free account.
How it is built
-
Scan redirect that answers first and logs after — the short-URL route returns the 302 redirect at once. Then Next.js
after()records the device, OS, browser, geo (from proxy headers), and a truncated IP. Only http(s) destinations are accepted. - Tracked-code reservations — a short code is held on a one-hour lease, so the live preview scans correctly before you save. Expired claims stay as tombstones, so a code can never point to another user’s destination. Tests cover retries and concurrent activation.
- Rate limits — three sliding-window limits on Upstash Redis (general API, reservation create, reservation change).
-
SEO — JSON-LD structured data, a tested sitemap, how-to guides, per-type landing pages,
/llms.txt, and security headers. - Tests — 98 automated test cases across 11 files with Vitest.
-
Deployment — a multi-stage Dockerfile (Next.js standalone output) on Coolify on Hetzner Cloud, with
prisma migrate deployat container start, a/api/healthendpoint, and Cloudflare in front. - Backups — hourly PostgreSQL backups to Backblaze B2. A restore test passed on 2026-09-14.
Summary
A two-mode QR generator built with Next.js.
- Client-side QR rendering (
qr-code-styling); PNG / SVG / PDF export (pdf-lib) all generated in the browser. - Tracked codes: a short-URL redirect that answers first and logs scan analytics after, with a destination you can edit after printing.
- Eight content types, from URLs to Wi-Fi to vCards, and a browser QR scanner.
- Upstash Redis rate limits, 98 Vitest test cases, and a reservation design with lease and tombstones.
- Clerk auth, Prisma + PostgreSQL; deployed with Docker on Coolify (Hetzner Cloud), with hourly backups and a tested restore.
This post is licensed under CC BY 4.0 by the author.
