qrcode.react vs qr.js vs react-qr-code vs qr-code-styling vs qrious
QR Code Generation Libraries Comparison
1 Year
qrcode.reactqr.jsreact-qr-codeqr-code-stylingqriousSimilar Packages:
What's QR Code Generation Libraries?

These libraries provide various functionalities for generating QR codes in web applications. They differ in terms of customization options, ease of use, and integration with frameworks like React. Each library caters to different needs, from simple QR code generation to advanced styling and customization features, making them suitable for various use cases in web development.

NPM Package Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
qrcode.react1,068,7613,931115 kB27a month agoISC
qr.js631,301---12 years agoMIT
react-qr-code476,24774313.6 kB137 months agoMIT
qr-code-styling166,4261,617515 kB693 days agoMIT
qrious44,6551,556-428 years agoGPL-3.0
Feature Comparison: qrcode.react vs qr.js vs react-qr-code vs qr-code-styling vs qrious

Customization Options

  • qrcode.react:

    qrcode.react provides basic customization options such as size and error correction level, but it is not as feature-rich as qr-code-styling. It is more suited for straightforward QR code generation.

  • qr.js:

    qr.js has limited customization options, focusing primarily on generating standard QR codes without additional styling features. It is best for scenarios where a simple QR code is sufficient.

  • react-qr-code:

    react-qr-code offers basic customization features, allowing developers to set size and level of error correction, making it easy to integrate into React applications.

  • qr-code-styling:

    qr-code-styling offers extensive customization options, allowing developers to change colors, shapes, and even add logos to the QR code. This makes it suitable for branding and marketing purposes where visual appeal is important.

  • qrious:

    qrious allows for some customization, such as size and color, but it is primarily focused on generating QR codes quickly rather than extensive styling options.

Ease of Use

  • qrcode.react:

    qrcode.react is designed for React developers, making it easy to integrate into existing React applications. Its API is straightforward, allowing for quick implementation.

  • qr.js:

    qr.js is very easy to use, with a simple API that allows for quick QR code generation without much setup. It is ideal for developers who want a no-fuss solution.

  • react-qr-code:

    react-qr-code is very easy to use, especially for those familiar with React. It integrates seamlessly into React components, making it a great choice for React developers.

  • qr-code-styling:

    qr-code-styling has a steeper learning curve due to its extensive features, but once mastered, it provides powerful capabilities for creating visually appealing QR codes.

  • qrious:

    qrious is user-friendly and provides a simple API for generating QR codes. It is suitable for developers looking for a balance between ease of use and functionality.

Integration with Frameworks

  • qrcode.react:

    qrcode.react is specifically designed for React applications, providing a seamless integration experience for React developers. It is the best choice for projects built with React.

  • qr.js:

    qr.js is framework-agnostic and can be easily integrated into any JavaScript project, making it a flexible choice for developers.

  • react-qr-code:

    react-qr-code is tailored for React, making it easy to use within React applications. It provides a straightforward way to generate QR codes directly in React components.

  • qr-code-styling:

    qr-code-styling can be used in any JavaScript environment, but it requires additional setup for integration with frameworks. It is versatile but may require more effort to implement in specific frameworks.

  • qrious:

    qrious can be used in various environments but does not have specific integrations for frameworks. It is suitable for general use cases but may require additional work for framework-specific implementations.

Performance

  • qrcode.react:

    qrcode.react performs well in React applications, providing efficient rendering of QR codes without significant performance hits.

  • qr.js:

    qr.js is lightweight and fast, making it an excellent choice for performance-sensitive applications where quick QR code generation is essential.

  • react-qr-code:

    react-qr-code is efficient and performs well within React applications, ensuring that QR codes are generated quickly without impacting overall application performance.

  • qr-code-styling:

    qr-code-styling may have slightly higher performance overhead due to its extensive customization features, but it is optimized for generating high-quality QR codes.

  • qrious:

    qrious is designed for performance and can generate QR codes quickly, making it suitable for applications that require dynamic QR code generation.

Community and Support

  • qrcode.react:

    qrcode.react benefits from the large React community, providing ample resources, tutorials, and support for developers.

  • qr.js:

    qr.js has a smaller community but offers basic documentation, making it suitable for developers who need a straightforward solution.

  • react-qr-code:

    react-qr-code is well-supported within the React ecosystem, with a strong community and resources available for troubleshooting and implementation.

  • qr-code-styling:

    qr-code-styling has a growing community and good documentation, providing support for developers looking to implement advanced features.

  • qrious:

    qrious has a moderate community presence, with decent documentation available for users looking to implement QR code generation.

How to Choose: qrcode.react vs qr.js vs react-qr-code vs qr-code-styling vs qrious
  • qrcode.react:

    Opt for qrcode.react if you are working within a React application and want a simple way to integrate QR code generation directly into your components. It provides a React-friendly API and is easy to use for developers familiar with React.

  • qr.js:

    Select qr.js for a lightweight and straightforward solution for generating QR codes without any dependencies. It is suitable for projects where simplicity and performance are priorities, and you don't need extensive customization.

  • react-qr-code:

    Choose react-qr-code if you want a React-specific library that is easy to use and integrates seamlessly with React components. It is perfect for developers looking for a simple and effective way to generate QR codes in their React applications.

  • qr-code-styling:

    Choose qr-code-styling if you need highly customizable QR codes with options for styling, colors, and logos. It is ideal for branding purposes and requires a bit more setup to take full advantage of its features.

  • qrious:

    Use qrious if you need a flexible solution that can generate QR codes in various formats (canvas or image). It is great for applications that require dynamic QR code generation and offers a straightforward API for quick implementation.

README for qrcode.react

qrcode.react

A React component to generate QR codes for rendering to the DOM.

Installation

npm install qrcode.react

Usage

qrcode.react exports two components, supporting rendering as SVG or Canvas. SVG is generally recommended as it is more flexible, but Canvas may be preferable.

All examples are shown using modern JavaScript modules and syntax. CommonJS require('qrcode.react') is also supported.

QRCodeSVG

import ReactDOM from 'react-dom';
import {QRCodeSVG} from 'qrcode.react';

ReactDOM.render(
  <QRCodeSVG value="https://reactjs.org/" />,
  document.getElementById('mountNode')
);

QRCodeCanvas

import ReactDOM from 'react-dom';
import {QRCodeCanvas} from 'qrcode.react';

ReactDOM.render(
  <QRCodeCanvas value="https://reactjs.org/" />,
  document.getElementById('mountNode')
);

Available Props

Below is a condensed type definition of the props QRCodeSVG and QRCodeCanvas accept.

type QRProps = {
  /**
   * The value to encode into the QR Code. An array of strings can be passed in
   * to represent multiple segments to further optimize the QR Code.
   */
  value: string | string[];
  /**
   * The size, in pixels, to render the QR Code.
   * @defaultValue 128
   */
  size?: number;
  /**
   * The Error Correction Level to use.
   * @see https://www.qrcode.com/en/about/error_correction.html
   * @defaultValue L
   */
  level?: 'L' | 'M' | 'Q' | 'H';
  /**
   * The background color used to render the QR Code.
   * @see https://developer.mozilla.org/en-US/docs/Web/CSS/color_value
   * @defaultValue #FFFFFF
   */
  bgColor?: string;
  /**
   * The foregtound color used to render the QR Code.
   * @see https://developer.mozilla.org/en-US/docs/Web/CSS/color_value
   * @defaultValue #000000
   */
  fgColor?: string;
  /**
   * Whether or not a margin of 4 modules should be rendered as a part of the
   * QR Code.
   * @deprecated Use `marginSize` instead.
   * @defaultValue false
   */
  includeMargin?: boolean;
  /**
   * The number of _modules_ to use for margin. The QR Code specification
   * requires `4`, however you can specify any number. Values will be turned to
   * integers with `Math.floor`. Overrides `includeMargin` when both are specified.
   * @defaultValue 0
   */
  marginSize?: number;
  /**
   * The title to assign to the QR Code. Used for accessibility reasons.
   */
  title?: string;
  /**
   * The minimum version used when encoding the QR Code. Valid values are 1-40
   * with higher values resulting in more complex QR Codes. The optimal
   * (lowest) version is determined for the `value` provided, using `minVersion`
   * as the lower bound.
   * @defaultValue 1
   */
  minVersion?: number;
  /**
   * If enabled, the Error Correction Level of the result may be higher than
   * the specified Error Correction Level option if it can be done without
   * increasing the version.
   * @defaultValue true
   */
  boostLevel?: boolean;
  /**
   * The settings for the embedded image.
   */
  imageSettings?: {
    /**
     * The URI of the embedded image.
     */
    src: string;
    /**
     * The height, in pixels, of the image.
     */
    height: number;
    /**
     * The width, in pixels, of the image.
     */
    width: number;
    /**
     * Whether or not to "excavate" the modules around the embedded image. This
     * means that any modules the embedded image overlaps will use the background
     * color.
     */
    excavate: boolean;
    /**
     * The horiztonal offset of the embedded image, starting from the top left corner.
     * Will center if not specified.
     */
    x?: number;
    /**
     * The vertical offset of the embedded image, starting from the top left corner.
     * Will center if not specified.
     */
    y?: number;
    /**
     * The opacity of the embedded image in the range of 0-1.
     * @defaultValue 1
     */
    opacity?: number;
    /**
     * The cross-origin value to use when loading the image. This is used to
     * ensure compatibility with CORS, particularly when extracting image data
     * from QRCodeCanvas.
     * Note: `undefined` is treated differently than the seemingly equivalent
     * empty string. This is intended to align with HTML behavior where omitting
     * the attribute behaves differently than the empty string.
     */
    crossOrigin?: 'anonymous' | 'use-credentials' | '' | undefined;
  };
};

value

The value to encode into the QR Code. See Encoding Mode for additional details.

| Type | Default Value | | -------------------- | ------------- | | string \| string[] | — |

size

The size, in pixels, to render the QR Code.

| Type | Default Value | | -------- | ------------- | | number | 128 |

level

The Error Correction Level to use. Information is encoded in QR Codes such that they can lose part of their visible areas and still be decodable. The amount of correction depends on this value. Higher error correction will result in more complex QR Codes.

  • L = low (~7%)
  • M = medium (~15%)
  • Q = quartile (~25%)
  • H = high (~30%)

See Wikipedia or the official QR Code documentation for a more detailed explaination.

| Type | Default Value | | ------------------ | ------------- | | L \| M \| Q \| H | L |

bgColor

The background color used to render the QR Code. This is passed directly to the Canvas (ctx.fillStyle = bgColor) or the SVG <path> (fill={bgColor}), both which accept any CSS color.

| Type | Default Value | | -------- | ------------- | | string | #FFFFFF |

fgColor

The foreground color used to render the QR Code. It follows the same constraints as bgColor

| Type | Default Value | | -------- | ------------- | | string | #000000 |

includeMargin

[!WARNING] This has been deprecated in v4 and will be removed in a future version. Use marginSize instead.

Whether or not a margin of 4 modules should be rendered as a part of the QR Code.

| Type | Default Value | | --------- | ------------- | | boolean | false |

marginSize

The number of modules to use for margin. The QR Code specification requires 4, however you can specify any number. Values will be turned to integers with Math.floor. Overrides includeMargin when both are specified.

| Type | Default Value | | -------- | ------------- | | number | 0 |

title

The title to assign to the QR Code. Used for accessibility reasons.

| Type | Default Value | | -------- | ------------- | | string | — |

minVersion

The minimum version used when encoding the QR Code. Valid values are 1-40 with higher values resulting in more complex QR Codes. The optimal (lowest) version is determined for the value provided, using minVersion as the lower bound.

| Type | Default Value | | -------- | ------------- | | number | 1 |

boostLevel

If enabled, the Error Correction Level of the result may be higher than the specified Error Correction Level option if it can be done without increasing the version.

| Type | Default Value | | --------- | ------------- | | boolean | true |

imageSettings

Used to specify the details for an embedded image, often used to embed a logo.

| Type | Default Value | | --------------------------- | ------------- | | object (see fields below) | — |

imageSettings.src

The URI of the embedded image. This will get passed directly to src of an img element for QRCodeCanvas or the href of an inline image for QRCodeSVG.

| Type | Default Value | | -------- | ------------- | | string | — |

imageSettings.height

The height, in pixels, of the embedded image.

| Type | Default Value | | -------- | ------------- | | number | — |

imageSettings.width

The width, in pixels, of the embedded image.

| Type | Default Value | | -------- | ------------- | | number | — |

imageSettings.excavate

Whether or not to "excavate" the modules around the embedded image. This means that any modules the embedded image overlaps will use the background color. Use this to ensure clean edges around your image. It is also useful when embedding images with transparency.

| Type | Default Value | | --------- | ------------- | | boolean | — |

imageSettings.x

The horizontal offset, in pixels, of the embedded image. Positioning follows standard DOM positioning, with top left corner being 0.

When not specified, will center the image.

| Type | Default Value | | -------- | ------------- | | number | — |

imageSettings.y

The vertical offset, in pixels, of the embedded image. Positioning follows standard DOM positioning, with top left corner being 0.

When not specified, will center the image.

| Type | Default Value | | -------- | ------------- | | number | — |

imageSettings.opacity

The opacity of the embedded image, in the range of 0 to 1.

| Type | Default Value | | -------- | ------------- | | number | 1 |

imageSettings.crossOrigin

The cross-origin value to use when loading the embedded image. Note that undefined works as typically does with React, excluding the attribute from the DOM node. This is intended to align with HTML behavior where omitting the attribute behaves differently than the empty string.

| Type | Default Value | | -------- | ------------- | | string | — |

Custom Styles

qrcode.react will pass through any additional props to the underlying DOM node (<svg> or <canvas>). This allows the use of inline style or custom className to customize the rendering. One common use would be to support a responsive layout.

[!NOTE] In order to render QR Codes in <canvas> on high density displays, we scale the canvas element to contain an appropriate number of pixels and then use inline styles to scale back down. We will merge any additional styles, with custom height and width overriding our own values. This allows scaling to percentages but if scaling beyond the size, you will encounter blurry images. I recommend detecting resizes with something like react-measure to detect and pass the appropriate size when rendering to <canvas>.

Encoding Mode

qrcode.react supports encoding text only. Prior to v4.1.0, this was done in a single segment. Since then, the value prop can be an array of strings. Each member will be encoded separately. The encoding library being used does minimal detection to determine if each segment being encoded can follow an optimized path for Numeric or Alphanumeric modes, allowing for more data to be encoded. Otherwise, it will encode following Byte mode. This mode includes supports multi-byte Unicode characters such as Kanji, however it does not support the optimized Kanji encoding mode.

LICENSE

qrcode.react is licensed under the ISC license.

qrcode.react bundles QR Code Generator, which is available under the MIT license.