DEV Community

RahulD
RahulD

Posted on

Dynamic vs Static QR Codes: A Developer's Guide

If you've ever built a feature involving QR codes, you've hit this question: should you generate a static code that encodes the URL directly, or a dynamic one that redirects through a short URL you control?

The answer depends on your architecture — and the tradeoffs are more interesting than most blog posts let on.

How static QR codes work

A static QR code encodes your payload directly into the dot matrix. When someone scans it, their phone decodes the raw bytes — no server, no redirect, no analytics. The URL https://qrgenlabs.com becomes part of the QR pattern itself.

Pros: works offline, no dependency on a redirect service, lower latency. Cons: if you need to update the destination, you have to reprint/republish the code.

How dynamic QR codes work

A dynamic QR code encodes a short redirect URL (e.g., https://qr.io/abc123) that resolves to your actual destination. When someone scans it, the flow is: decode short URL → HTTP 301/302 to destination → user lands.

This gives you the ability to update the destination without touching the printed code, and it gives you a place to log scan events: timestamp, device OS, city (via IP geolocation), referrer.

Scan tracking architecture

Here's a minimal implementation. On scan, your redirect service receives the hit. Before the redirect fires, log the event:

Parse User-Agent for device type (mobile/desktop, OS)
IP → geo lookup for approximate city/country
Write event to time-series store (Redis Streams works well here)
Respond with 302 to destination URL

This is exactly what tools like QRGenLabs do under the hood — their analytics dashboard surfaces per-day scans, device breakdowns, and location heatmaps in real time.

Which should you use?

Static codes are right for: permanent links (your website, GitHub, a PDF that won't move), offline contexts, or when you want zero third-party dependency.

Dynamic codes are right for: marketing campaigns, restaurant menus, event signage, product packaging — anywhere you might need to update the destination or want attribution data.

The good news: if you're not building the redirect service yourself, QRGenLabs lets you generate both types. Static codes are free forever (no expiry), dynamic codes come with a full analytics dashboard. I use it for my own projects because it handles the SVG export cleanly for print work.

Top comments (0)