npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@qrcodesdk/react

v0.0.1

Published

@qrcodesdk/react provides React components for rendering QR codes as SVG, PNG-backed image elements, and canvas elements.

Readme

@qrcodesdk/react

Open @qrcodesdk/react on npmx.dev @qrcodesdk/react version @qrcodesdk/react install size @qrcodesdk/react download/mo @qrcodesdk/react Source code

Live Demo

@qrcodesdk/react provides React components for rendering QR codes as inline SVG, PNG-backed Image elements, and Canvas elements.

It supports React and React DOM 18 and 19.

Install

npm install @qrcodesdk/react @qrcodesdk/core @qrcodesdk/browser
pnpm add @qrcodesdk/react @qrcodesdk/core @qrcodesdk/browser

vp

vp add @qrcodesdk/react @qrcodesdk/core @qrcodesdk/browser

deno

deno add @qrcodesdk/react @qrcodesdk/core @qrcodesdk/browser

bun

bun add @qrcodesdk/react @qrcodesdk/core @qrcodesdk/browser

yarn

yarn add @qrcodesdk/react @qrcodesdk/core @qrcodesdk/browser

Quick start

Import the components directly where you need them:

import {QRCodeCanvas, QRCodeImage, QRCodeSVG} from '@qrcodesdk/react';

export function App() {
  return (
    <>
      <QRCodeSVG data="https://qrcodesdk.dev" />
      <QRCodeImage data="https://qrcodesdk.dev" />
      <QRCodeCanvas data="https://qrcodesdk.dev" />
    </>
  );
}

Components

| Component | Output | Download support | | -------------- | ------------------------------------------- | ---------------- | | QRCodeSVG | Inline SVG inside a wrapper <div> | SVG | | QRCodeImage | PNG-backed <img> inside a wrapper <div> | PNG | | QRCodeCanvas | <canvas> inside a wrapper <div> | None |

All components accept:

| Prop | Type | Description | | ----------- | -------------------------- | ----------------------------------------------- | | data | string \| number | Required QR code payload. | | options | Component-specific options | Optional matrix and renderer configuration. | | className | string | CSS class applied to the component wrapper div. |

options supports shared matrix options such as version, mode, errorCorrectionLevel, and mask. Renderer options match the corresponding QRCodeSDK renderer:

  • QRCodeSVG uses QRCodeSVGOptions.
  • QRCodeImage uses QRCodeImageOptions.
  • QRCodeCanvas uses QRCodeCanvasOptions.

Import QRCodeSVGOptions from @qrcodesdk/core. Import QRCodeImageOptions and QRCodeCanvasOptions from @qrcodesdk/browser.

Matrix options

The options prop combines the component's renderer options with the shared QR matrix options:

| Option | Type | Default | Description | | ---------------------- | ---------------------------------------- | --------- | ----------------------- | | mode | 'numeric' \| 'alphanumeric' \| 'octet' | Automatic | Encoding mode. | | errorCorrectionLevel | 'L' \| 'M' \| 'Q' \| 'H' | 'M' | Error correction level. | | version | 1 through 40 | Automatic | Pins the QR version. | | mask | 0 through 7 | Automatic | Pins the QR mask. |

Most applications should let the builder select the mode, version, and mask automatically.

Live examples

SVG component

import {QRCodeSVG} from '@qrcodesdk/react';

export default function QRCodeSVGExample() {
  return (
    <QRCodeSVG
      data="https://qrcodesdk.dev"
      options={{
        title: 'QR code for qrcodesdk.dev',
        ariaLabel: 'Scan to open qrcodesdk.dev',
      }}
    />
  );
}

Image component

import type {QRCodeImageOptions} from '@qrcodesdk/browser';
import {QRCodeImage} from '@qrcodesdk/react';

export default function QRCodeImageExample() {
  const options: QRCodeImageOptions = {
    size: 8,
    margin: 4,
    alt: 'QR code for qrcodesdk.dev',
    ariaLabel: 'Scan to open qrcodesdk.dev',
  };

  return <QRCodeImage data="https://qrcodesdk.dev" options={options} />;
}

Canvas component

import type {QRCodeCanvasOptions} from '@qrcodesdk/browser';
import {QRCodeCanvas} from '@qrcodesdk/react';

export default function QRCodeCanvasExample() {
  const options: QRCodeCanvasOptions = {
    size: 8,
    margin: 4,
    colors: {
      colorDark: '#111827',
      colorLight: '#ffffff',
    },
  };

  return <QRCodeCanvas data="https://qrcodesdk.dev" options={options} />;
}

PNG download

import {useRef} from 'react';

import {QRCodeImage, type QRCodeDownloadHandle} from '@qrcodesdk/react';

export default function QRCodeDownloadImageExample() {
  const qrcode = useRef<QRCodeDownloadHandle>(null);

  return (
    <div className="flex flex-col items-center">
      <QRCodeImage
        data="https://qrcodesdk.dev"
        options={{
          alt: 'QR code for qrcodesdk.dev',
        }}
        ref={qrcode}
      />
      <button
        className="btn-primary"
        onClick={() => qrcode.current?.download('qrcodesdk')}
        type="button">
        Download PNG
      </button>
    </div>
  );
}

Renderer options

| Option | Components | Type | Default | | ----------------------- | ---------- | ---------------------------- | -----------------: | | size | All | number | 5 | | margin | All | number | 4 | | colors.colorDark | All | string | '#000000' | | colors.colorLight | All | string | '#ffffff' | | dotsOptions | All | QRCodeDotsOptions | {type: 'square'} | | cornersSquareOptions | All | QRCodeCornersSquareOptions | {type: 'square'} | | cornersDotOptions | All | QRCodeCornersDotOptions | {type: 'square'} | | alt | SVG, Image | string | undefined | | ariaLabel | SVG, Image | string | undefined | | title | SVG, Image | string | undefined | | image.source | All | Renderer-specific source | undefined | | image.size | All | number | 0.4 | | image.padding | All | number | 1 | | image.clearBackground | All | boolean | true |

Color options use hash-prefixed values such as #111827. All built-in renderers require a positive safe integer size and a non-negative safe integer margin.

Module, finder-ring, and finder-center options pass through to every component. Their optional colors independently inherit colors.colorDark.

Prepared center images

Prepare browser image sources before rendering:

import {useState} from 'react';

import {QRCodeImage} from '@qrcodesdk/react';

export function QRCodeWithLogo() {
  const [logo, setLogo] = useState<HTMLImageElement>();

  async function selectLogo(file: File) {
    const source = new Image();
    const localUrl = URL.createObjectURL(file);
    source.src = localUrl;

    try {
      await source.decode();
      setLogo(source);
    } finally {
      URL.revokeObjectURL(localUrl);
    }
  }

  return (
    <>
      <input
        accept="image/*"
        type="file"
        onChange={(event) => {
          const file = event.currentTarget.files?.[0];
          if (file) void selectLogo(file);
        }}
      />
      {logo ? (
        <QRCodeImage
          data="https://qrcodesdk.dev"
          options={{errorCorrectionLevel: 'H', image: {source: logo, size: 0.3}}}
        />
      ) : null}
    </>
  );
}

Use an embedded data:image/... URL for QRCodeSVG. Components never load paths or URLs themselves, and SVG/PNG downloads include the overlay.

Download files

  • QRCodeSVG exposes download(filename?) and writes an SVG file through a React ref.
  • QRCodeImage exposes download(filename?) and writes a PNG file through a React ref.
import {useRef} from 'react';

import {QRCodeImage, type QRCodeDownloadHandle} from '@qrcodesdk/react';

export function QRCodeDownload() {
  const qrcode = useRef<QRCodeDownloadHandle>(null);

  return (
    <>
      <button type="button" onClick={() => qrcode.current?.download('qrcodesdk')}>
        Download PNG
      </button>
      <QRCodeImage ref={qrcode} data="https://qrcodesdk.dev" />
    </>
  );
}

The appropriate .svg or .png extension is appended when necessary.

QRCodeCanvas does not include a download method. Use QRCodeImage when you want built-in PNG download support.

Server-side rendering

QRCodeSVG produces runtime-neutral SVG and can render on the server.

QRCodeImage and QRCodeCanvas rely on browser DOM and Canvas APIs, so they skip element creation and downloads outside the browser and populate their host after hydration.

Documentation