qrcode.react vs react-qr-code vs qr.js vs qr-code-styling vs qrious
QR 코드 생성 라이브러리
qrcode.reactreact-qr-codeqr.jsqr-code-stylingqrious유사 패키지:

QR 코드 생성 라이브러리

QR 코드 생성 라이브러리는 웹 애플리케이션에서 QR 코드를 쉽게 생성할 수 있도록 도와주는 도구입니다. 이 라이브러리들은 다양한 기능과 스타일링 옵션을 제공하여, 사용자가 원하는 형태로 QR 코드를 만들 수 있게 합니다. 예를 들어, qr-code-styling은 QR 코드의 디자인을 커스터마이징할 수 있는 기능을 제공하며, qr.js는 가볍고 빠른 QR 코드 생성에 중점을 둔 라이브러리입니다. qrcode.react와 react-qr-code는 React 환경에서 QR 코드를 생성할 수 있는 컴포넌트를 제공하며, qrious는 HTML5 캔버스를 활용한 QR 코드 생성에 특화되어 있습니다.

npm 다운로드 트렌드

3 년

GitHub Stars 순위

통계 세부사항

패키지
다운로드
Stars
크기
Issues
발행일
라이선스
qrcode.react14,992,5894,296115 kB442年前ISC
react-qr-code4,076,62089519.9 kB85ヶ月前MIT
qr.js2,518,699---14年前MIT
qr-code-styling1,228,0732,987516 kB1172年前MIT
qrious91,8831,616-449年前GPL-3.0

기능 비교: qrcode.react vs react-qr-code vs qr.js vs qr-code-styling vs qrious

디자인 및 스타일링

  • qrcode.react:

    qrcode.react는 React 환경에서 QR 코드를 생성할 수 있는 컴포넌트를 제공하지만, 디자인 옵션은 제한적입니다. 기본적인 스타일링은 가능하지만, 복잡한 커스터마이징은 어렵습니다.

  • react-qr-code:

    react-qr-code는 간단한 스타일링 옵션을 제공하는 React 컴포넌트입니다. 색상과 크기를 조절할 수 있지만, 복잡한 디자인 커스터마이징은 지원하지 않습니다.

  • qr.js:

    qr.js는 기본적인 QR 코드 생성 기능만을 제공하며, 디자인이나 스타일링에 대한 옵션은 거의 없습니다. 따라서 빠르고 간단한 QR 코드가 필요할 때 적합합니다.

  • qr-code-styling:

    qr-code-styling은 QR 코드의 디자인을 자유롭게 커스터마이징할 수 있는 기능을 제공합니다. 색상, 모양, 로고 삽입 등 다양한 옵션을 통해 브랜드에 맞는 독특한 QR 코드를 만들 수 있습니다.

  • qrious:

    qrious는 캔버스 기반으로 QR 코드를 생성하며, 크기와 색상을 조절할 수 있는 기본적인 스타일링 기능을 제공합니다. 그러나 고급 디자인 옵션은 제공하지 않습니다.

성능 및 크기

  • qrcode.react:

    qrcode.react는 React 컴포넌트로서, QR 코드 생성 시 React의 렌더링 메커니즘을 활용합니다. 성능은 비교적 우수하지만, 대량의 QR 코드를 생성할 때는 주의가 필요합니다.

  • react-qr-code:

    react-qr-code는 경량의 React 컴포넌트로, 빠르고 효율적으로 QR 코드를 생성할 수 있습니다. 성능 저하 없이 다양한 크기의 QR 코드를 렌더링할 수 있습니다.

  • qr.js:

    qr.js는 매우 가벼운 라이브러리로, 빠른 QR 코드 생성이 가능합니다. 불필요한 기능이 없기 때문에 성능에 민감한 애플리케이션에 적합합니다.

  • qr-code-styling:

    qr-code-styling은 디자인 기능이 풍부한 만큼, 다른 라이브러리보다 다소 무거울 수 있습니다. 그러나 적절한 최적화를 통해 실시간으로 스타일링된 QR 코드를 생성할 수 있습니다.

  • qrious:

    qrious는 캔버스 기반으로 QR 코드를 생성하므로, 그래픽 렌더링이 빠르고 효율적입니다. 크기가 크지 않아 웹 애플리케이션에 쉽게 통합할 수 있습니다.

React 통합

  • qrcode.react:

    qrcode.react는 React 전용 라이브러리로, QR 코드를 컴포넌트 형태로 쉽게 삽입할 수 있습니다. React 프로젝트에 최적화되어 있어 사용이 간편합니다.

  • react-qr-code:

    react-qr-code는 React 환경에 최적화된 QR 코드 생성 컴포넌트로, 간단한 API와 빠른 렌더링을 제공합니다. React 프로젝트에 쉽게 통합할 수 있습니다.

  • qr.js:

    qr.js는 순수 JavaScript 라이브러리로, React와의 통합을 위해 별도의 래퍼 컴포넌트를 만들어야 합니다. 간단한 기능 덕분에 통합은 비교적 쉽습니다.

  • qr-code-styling:

    qr-code-styling은 React와 직접적인 통합 기능을 제공하지 않지만, 커스텀 컴포넌트를 만들어 사용할 수 있습니다. 스타일링 기능이 뛰어나지만, React 환경에서 사용하려면 추가 작업이 필요합니다.

  • qrious:

    qrious는 React 전용 기능을 제공하지 않지만, 캔버스 요소를 활용하여 React 컴포넌트 내에서 사용할 수 있습니다. 통합을 위해 약간의 작업이 필요합니다.

사용 예제

  • qrcode.react:

    qrcode.react를 사용하여 React 컴포넌트 내에서 QR 코드를 생성하는 예제입니다.

    import { QRCode } from 'qrcode.react';
    function App() {
      return <QRCode value="https://example.com" size={256} fgColor="#000" bgColor="#fff" />;
    }
    export default App;
    
  • react-qr-code:

    react-qr-code를 사용하여 간단한 React 컴포넌트 내에서 QR 코드를 생성하는 예제입니다.

    import QRCode from 'react-qr-code';
    function App() {
      return <QRCode value="https://example.com" />;
    }
    export default App;
    
  • qr.js:

    qr.js를 사용하여 간단한 QR 코드를 생성하는 예제입니다.

    import QRCode from 'qr.js';
    const qr = new QRCode('https://example.com');
    const canvas = document.createElement('canvas');
    const ctx = canvas.getContext('2d');
    canvas.width = qr.moduleCount * 10;
    canvas.height = qr.moduleCount * 10;
    for (let row = 0; row < qr.moduleCount; row++) {
      for (let col = 0; col < qr.moduleCount; col++) {
        ctx.fillStyle = qr.isDark(row, col) ? '#000' : '#fff';
        ctx.fillRect(col * 10, row * 10, 10, 10);
      }
    }
    document.body.appendChild(canvas);
    
  • qr-code-styling:

    qr-code-styling을 사용하여 커스터마이징된 QR 코드를 생성하는 예제입니다.

    import QRCodeStyling from 'qr-code-styling';
    const qrCode = new QRCodeStyling({
      width: 300,
      height: 300,
      data: 'https://example.com',
      image: 'logo.png',
      dotsOptions: {
        color: '#4267b2',
        type: 'rounded'
      },
      backgroundOptions: {
        color: '#e9ebee',
      },
      imageOptions: {
        crossOrigin: 'anonymous',
        margin: 20
      }
    });
    qrCode.append(document.getElementById('qr-code'));
    
  • qrious:

    qrious를 사용하여 캔버스 기반 QR 코드를 생성하는 예제입니다.

    import { Qrious } from 'qrious';
    const qr = new Qrious({
      element: document.getElementById('qr'),
      value: 'https://example.com',
      size: 200,
      background: '#fff',
      foreground: '#000'
    });
    

선택 방법: qrcode.react vs react-qr-code vs qr.js vs qr-code-styling vs qrious

  • qrcode.react:

    React 프로젝트에서 쉽게 QR 코드를 생성하려면 qrcode.react를 사용하세요. 이 라이브러리는 React 컴포넌트 형태로 제공되어, JSX 내에서 간편하게 QR 코드를 삽입할 수 있습니다.

  • react-qr-code:

    간단하고 직관적인 React용 QR 코드 컴포넌트를 원한다면 react-qr-code를 선택하세요. 이 라이브러리는 사용하기 쉽고, 기본적인 QR 코드 생성 기능을 제공하며, 스타일링도 간편합니다.

  • qr.js:

    가볍고 빠른 QR 코드 생성이 필요하다면 qr.js가 적합합니다. 이 라이브러리는 최소한의 기능만을 제공하지만, 그만큼 빠르고 효율적으로 QR 코드를 생성할 수 있습니다.

  • qr-code-styling:

    디자인과 스타일링이 중요한 경우 qr-code-styling을 선택하세요. 이 라이브러리는 색상, 모양, 로고 삽입 등 다양한 커스터마이징 옵션을 제공하여, 브랜드에 맞는 독특한 QR 코드를 만들 수 있습니다.

  • qrious:

    HTML5 캔버스를 활용한 QR 코드 생성이 필요하다면 qrious가 좋은 선택입니다. 이 라이브러리는 캔버스 기반으로 QR 코드를 생성하며, 크기와 색상을 쉽게 조절할 수 있습니다.

qrcode.react의 README

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.

TypeDefault Value
string | string[]—

size

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

TypeDefault Value
number128

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.

TypeDefault Value
L | M | Q | HL

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.

TypeDefault Value
string#FFFFFF

fgColor

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

TypeDefault 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.

TypeDefault Value
booleanfalse

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.

TypeDefault Value
number0

title

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

TypeDefault 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.

TypeDefault Value
number1

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.

TypeDefault Value
booleantrue

imageSettings

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

TypeDefault 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.

TypeDefault Value
string—

imageSettings.height

The height, in pixels, of the embedded image.

TypeDefault Value
number—

imageSettings.width

The width, in pixels, of the embedded image.

TypeDefault 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.

TypeDefault 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.

TypeDefault 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.

TypeDefault Value
number—

imageSettings.opacity

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

TypeDefault Value
number1

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.

TypeDefault 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.