react-qr-code vs react-qr-reader vs react-qr-scanner
Displaying QR Codes Versus Reading Them in React
react-qr-codereact-qr-readerreact-qr-scannerSimilar Packages:

Displaying QR Codes Versus Reading Them in React

react-qr-code renders text as a QR image, whereas react-qr-reader and react-qr-scanner read camera frames. The two scanners expose different callbacks and host requirements; neither should be selected solely because an older README looks familiar.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
react-qr-code3,981,28089519.9 kB85 months agoMIT
react-qr-reader263,0841,1524.38 MB148-MIT
react-qr-scanner13,497-2.1 MB--ISC

First choose the data direction

react-qr-code takes a value and displays a QR code. Its web output is SVG, not an optional Canvas renderer. Size, foreground/background colors and error-correction level customize the symbol. The application supplies spacing around it. Its React Native route additionally needs react-native-svg. A displayed QR code and a camera decoder are complementary pieces of an application, not alternative implementations of the same step.

Camera components have different contracts

react-qr-reader exports QrReader and a related hook. Configure camera constraints and handle onResult's decoded result and error values. scanDelay controls the scanning interval, and styling props target the containing and video elements. The current latest package is a prerelease and declares React and React DOM peers in the React 16.8/17 families. Do not interpret its broad introductory wording as verified support for every later host. Its camera effect is established on mount, so prop changes should not be assumed to restart an existing session.

react-qr-scanner's current default component accepts constraints, onScan, onError, onLoad, resolution and qrArea. It creates a canvas during rendering and processes video frames through a worker. onScan receives a decoded result object with the current canvas, or null for a frame without a result. Adapt the result rather than treating it as a plain string. It declares React/React DOM 17 or 18 and is also a prerelease.

The scanner's packaged README describes older controls such as delay, facingMode and legacyMode. Those are not the scan controls implemented by the current exported component; a file-selection flow cannot be assumed from that text. Its ESM entry also imports runtime helpers not declared as production dependencies, so check module resolution in the consuming build.

Plan the surrounding user flow

A camera screen needs actual browser media support, camera availability and application handling for initialization, scan results and cleanup. Scanning no code in one frame differs from failing to initialize a camera. The application decides when to accept a result, pause or close the scanning view, and what to do with the decoded text.

Keep scanner components within the browser lifecycle. Switching scanner packages requires mapping props, callbacks and result objects; switching to the generator changes the entire task. None of these contracts justifies describing one scanner as a universal successor to the other.

How to Choose: react-qr-code vs react-qr-reader vs react-qr-scanner

  • react-qr-code:

    Use it to display a supplied string as SVG. Provide surrounding whitespace and contrast; it neither opens a camera nor decodes an image.

  • react-qr-reader:

    Use its named QrReader component for a camera workflow with constraints, scanDelay and onResult. Its current latest is a prerelease with React/React DOM 16.8 or 17 peers.

  • react-qr-scanner:

    Consider its browser-only camera component when React/React DOM 17 or 18 and its result-object contract fit. Its latest is a prerelease; use the actual constraints/resolution/qrArea interface rather than old legacyMode examples.

README for react-qr-code

react-qr-code

npm package

A component for React. This library works with React and React Native (using React Native SVG).

Screenshots

Web

Android & iOS

Installation

npm i react-qr-code

When using this library with React Native, you will also need to have react-native-svg installed.

npm i react-native-svg
cd ios && pod install

The Gist

import React from "react";
import ReactDOM from "react-dom";
import QRCode from "react-qr-code";

ReactDOM.render(<QRCode value="hey" />, document.getElementById("Container"));

Note: If the QR code is likely to appear next to dark objects, you will need to wrap it in a light-colored container to preserve the 'quiet zone', e.g.

<div style={{ background: 'white', padding: '16px' }}>
  <QRCode ... />
</div>

Responsive QR code example:

// Can be anything instead of `maxWidth` that limits the width.
<div style={{ height: "auto", margin: "0 auto", maxWidth: 64, width: "100%" }}>
  <QRCode
    size={256}
    style={{ height: "auto", maxWidth: "100%", width: "100%" }}
    value={value}
    viewBox={`0 0 256 256`}
  />
</div>

API

proptypedefault valueplatform
bgColorstring'#FFFFFF'web, ios, android
fgColorstring'#000000'web, ios, android
levelstring ('L' 'M' 'Q' 'H')'L'web, ios, android
sizenumber256web, ios, android
titlestringweb
valuestringweb, ios, android

Adheres to the official QR spec and can store up to 2953 characters in value.

Non-ASCII / UTF-8 text

react-qr-code encodes data in UTF-8 byte mode to ensure non-ASCII text (e.g., Korean, Japanese, emoji) renders and scans correctly. Just pass a normal JavaScript string:

<QRCode value="한글 테스트 😊" />

No additional encoding is required on your side.

Testing UTF-8 locally

  1. Build the demo library bundle in watch mode:
    • In one terminal: npm run demo-web-watch
  2. Run the demo app:
    • In another terminal: npm run demo
  3. Open the demo in your browser (Expo starts it automatically) and type a non-ASCII value (e.g., 안녕하세요, こんにちは, or an emoji) into the input.
  4. Scan the QR code with a phone camera app. The decoded text should match exactly.

License

MIT