QR Share

Reads the exact URL back under a QR code and re-decodes what it drew, so a shared code doesn't open the wrong page.

StopsQR code opens the wrong page

Installation

pnpm dlx shadcn@latest add https://bollard-ui.vercel.app/r/qr-share.json

The files land in your project. They're yours to edit.

Usage

qr-share-usage.tsx
import { QrShare } from "@/components/ui/qr-share"

<QrShare
  defaultValue="http://localhost:3000/rsvp/launch-2026?utm_source=print&utm_medium=qr&utm_campaign=launch-week-table-cards&utm_content=table-12"
  publicOrigin="https://acme.events"
/>

What it catches

  • localhost or staging URLs, with a swap to publicOrigin
  • http instead of https
  • Invisible characters in the URL, marked with their code point
  • Links long enough to make a dense, hard-to-scan code
  • Encoder output that doesn't decode back to the URL

Props

QrShare props
PropTypeDefault
value

Controlled URL.

string—
defaultValue

Initial URL when uncontrolled.

string""
onValueChange

Called with the new URL when a one-tap fix is used.

(value: string) => void—
publicOrigin

The live origin (e.g. "https://acme.com") offered in place of localhost or staging.

string—
size

Rendered width of the code in px, quiet zone included.

number176
denseVersion

Version from which a code counts as dense (7 = 45×45 dots).

number7
messages

Overrides for the issue messages in `QR_MESSAGES`.

Partial<typeof QR_MESSAGES>—
verifiedText

Templates: `{count}` (characters), `{modules}` and `{print}` are filled in.

string"Scans back as exactly these {count} characters · {module…
mismatchText

Shown when the drawn code doesn't decode back to the URL.

string"This code doesn't scan back as the link above. Don't sha…

* required. Also accepts the native props of <div> (className, aria-*, data-*…), passed through to it.

Accessibility

  • QR SVG is role=img with an aria-label naming the URL
  • Issues are a polite live region; a decode mismatch uses role=alert
  • Draw animation is skipped under reduced motion

Only what the source does. Test with your own screen reader and content before shipping.

Limitations

  • Byte mode and error correction M only; no logos or other ECC levels
  • Self-check proves the matrix, not that printers or screens reproduce it well

What it stops

QR code opens the wrong page

Also known as

qr code · qr generator · share · url · menu qr · poster · upi qr · print

Field type

Dependencies

Pairs well with