useQrCode

QrCode
stable

Headless QR-code composable. Encodes a string payload using qrcode-generator (Reed-Solomon + matrix masking) and returns a reactive SVG string, the raw module matrix, and the matrix size. The encoder is LRU-cached at module level to avoid rebuilding identical matrices on re-renders. Fully SSR-safe — no DOM API is touched.

API

Signature

Signature TypeScript complète extraite du fichier du composable.

typescript

Interfaces consommées

IUseQrCodeOptions
IQrCodeLogo

API

Paramètres

Paramètres d'entrée acceptés par ce composable.

value
requis
MaybeRefOrGetter<string>
The payload to encode: URL, text, vCard, etc. Accepts a plain string, a ref, or a getter function. Reactive — the SVG rebuilds whenever value changes.
options
MaybeRefOrGetter<IUseQrCodeOptions>
{}
Encoding and rendering options: errorCorrectionLevel ("L" | "M" | "Q" | "H"), foreground, background, margin (module units), cornerRadius (per <rect>), and logo ({ src, size, padding, background }).

API

Valeurs de retour

Propriétés et méthodes exposées par l'objet retourné par le composable.

svg
Complete SVG string with a viewBox scaled to the module grid. Safe for v-html or <img src="data:image/svg+xml,…">. Rebuilds when value or options change.
modules
N×N boolean grid where true = dark module. Use to render a custom canvas or WebGL QR code.
size
The side length of the module matrix (modules.value.length). Grows with payload complexity and ECC level.

Usage

Exemples

Extraits de code prêts à coller.

Basic reactive QR code

vue

Via OrigamQrCode component

vue

Custom canvas rendering using modules

vue