QRCode.react generates QR codes as React components for the DOM. It exports SVG and Canvas renderers with configurable size, colors, and error correction.
Overview
QRCode.react is a React component library for generating QR codes and rendering them into the DOM. It ships two components, QRCodeSVG and QRCodeCanvas; documentation recommends SVG for flexibility while Canvas may suit other needs. CommonJS require is supported alongside ES modules.
The value prop holds text to encode, as a string or array of strings so segments can be encoded separately with numeric, alphanumeric, or byte modes. Props control pixel size, error correction level L through H, foreground and background CSS colors, quiet zone margin, minimum QR version, and whether boost can raise correction without increasing version.
imageSettings embed a logo or image with size, position, opacity, crossOrigin, and optional excavation so underlying modules use the background color. Additional props pass through to the root SVG or canvas node for styling and responsive layouts. High-density displays scale the canvas internally; custom width and height can override defaults.
The library bundles QR Code Generator under MIT while QRCode.react itself uses ISC. Encoding supports multi-byte Unicode in byte mode but not optimized Kanji mode. A hosted demo page exercises the full prop surface and download patterns.
Key features
- QRCodeSVG and QRCodeCanvas components
- Configurable error correction levels
- Embedded image with excavation option
- Multi-segment string array encoding
- CSS color and margin controls
- Accessibility title prop
- Pass-through DOM styling props
Use cases
- Payment or login QR displays in React apps
- Event tickets with embedded logos
- Marketing pages with downloadable codes
- Two-factor setup flows in SPAs