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

@qr-kit/react

v1.2.1

Published

React component and hook for QR code generation — shapes, gradients, logos, overlays, frames, and finder pattern customization

Readme

@qr-kit/react

React component and hook for generating QR codes. Zero-dependency QR engine with custom rendering — shapes, gradients, logos, overlays, frames, and finder pattern customization.

0.95 KB gzipped (+ 21.9 KB for core + dom, installed automatically).

Install

npm install @qr-kit/react

Requires React 18+. Automatically installs @qr-kit/core and @qr-kit/dom.

Quick Start

import { QRCode } from '@qr-kit/react';

function App() {
  return <QRCode value="https://example.com" size={256} />;
}

Styling

<QRCode
  value="https://example.com"
  size={300}
  fgColor="#1a1a2e"
  bgColor="#ffffff"
  bgOpacity={0.8}
  borderRadius={10}
  shape="rounded"
  moduleScale={0.9}
  margin={4}
/>

Gradients

<QRCode
  value="https://example.com"
  size={300}
  fgColor={{
    type: 'linear',
    colors: ['#667eea', '#764ba2'],
    angle: 135,
  }}
/>

Finder Pattern Customization

<QRCode
  value="https://example.com"
  size={300}
  shape="dots"
  finderShape="rounded"
  finderColor="#e94560"
  // Granular control:
  finderOuterShape="rounded"
  finderInnerShape="circle"
  finderOuterColor="#e94560"
  finderInnerColor="#333333"
/>

Logo Embedding

<QRCode
  value="https://example.com"
  size={300}
  logo={{
    src: "/logo.png",
    width: 50,
    height: 50,
    padding: 5,
  }}
/>

Error correction is automatically upgraded to 'H' when a logo is present.

Overlay Image

<QRCode
  value="https://example.com"
  size={300}
  overlayImage={{
    src: "/background.png",
    opacity: 0.3,
    finderBackgroundColor: "#ffffff",
  }}
/>

Error correction is automatically upgraded to 'H' when an overlay is present.

Halftone Effect

Shape QR modules to approximate a target image:

<QRCode
  value="https://example.com"
  size={300}
  halftone={{
    image: { data: rgbaPixels, width: 200, height: 200 },
    strength: 0.7,    // 0-1
    threshold: 128,   // 0-255
  }}
/>

Accepts a PNG data URI string or raw RGBA pixel data. Error correction is automatically upgraded to 'H' when halftone is present.

Frame

<QRCode
  value="https://example.com"
  size={300}
  frame={{
    style: 'rounded',
    color: '#333333',
    thickness: 3,
    label: 'Scan me',
    labelPosition: 'bottom',
    labelColor: '#333333',
    labelFontSize: 14,
    padding: 8,
  }}
/>

Presets

<QRCode
  value="https://example.com"
  size={300}
  preset="elegant"
  fgColor="#1a1a2e"   // explicit props override preset values
/>

Available presets: 'default' | 'minimal' | 'rounded' | 'dots' | 'sharp' | 'elegant'

Custom Module Renderer

<QRCode
  value="https://example.com"
  size={300}
  customModule={({ x, y, size, row, col, moduleType }) => {
    return `<circle cx="${x + size / 2}" cy="${y + size / 2}" r="${size / 3}" fill="red"/>`;
  }}
/>

Imperative Handle (ref)

Access download/export methods via ref:

import { useRef } from 'react';
import { QRCode } from '@qr-kit/react';
import type { QRCodeHandle } from '@qr-kit/react';

function App() {
  const qrRef = useRef<QRCodeHandle>(null);

  return (
    <>
      <QRCode ref={qrRef} value="https://example.com" size={256} />
      <button onClick={() => qrRef.current?.download('my-qr.png')}>
        Download
      </button>
    </>
  );
}

QRCodeHandle methods

| Method | Returns | Description | |--------|---------|-------------| | download(filename?) | void | Trigger a file download (browser only) | | toBlob() | Blob | Get QR as a Blob (browser only) | | toDataURL() | string | Get QR as a data URL string | | element | HTMLDivElement \| null | Access the underlying DOM element |

useQRCode Hook

For custom rendering (Canvas, WebGL, etc.), use the hook to get the raw QR matrix:

import { useQRCode } from '@qr-kit/react';

function CustomQR() {
  const { matrix, moduleTypes, version, size, errorCorrection } = useQRCode({
    value: 'https://example.com',
    errorCorrection: 'H',
  });

  return <canvas ref={/* render matrix yourself */} />;
}

UseQRCodeOptions

| Option | Type | Default | Description | |--------|------|---------|-------------| | value | string | required | Data to encode | | errorCorrection | 'L' \| 'M' \| 'Q' \| 'H' | 'M' | Error correction level | | version | number | auto | QR version (1-40) | | hasLogo | boolean | false | Auto-upgrade EC to 'H' |

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | value | string | required | Data to encode | | size | number | 256 | Output size in pixels | | errorCorrection | 'L' \| 'M' \| 'Q' \| 'H' | 'M' | Error correction level | | version | number | auto | QR version (1-40) | | fgColor | string \| GradientConfig | '#000000' | Foreground color or gradient | | bgColor | string | '#ffffff' | Background color | | bgOpacity | number | 1 | Background opacity (0-1) | | borderRadius | number | 0 | Outer border radius in pixels | | shape | 'square' \| 'rounded' \| 'dots' \| 'diamond' | 'square' | Module shape | | moduleScale | number | 1 | Scale factor for modules (0-1) | | customModule | function | - | Custom SVG module renderer | | finderShape | 'square' \| 'rounded' \| 'circle' | matches shape | Finder pattern shape | | finderColor | string \| GradientConfig | matches fgColor | Finder pattern color | | finderOuterShape | FinderShape | matches finderShape | Outer finder ring shape | | finderInnerShape | FinderShape | matches finderShape | Inner finder dot shape | | finderOuterColor | string \| GradientConfig | matches finderColor | Outer finder ring color | | finderInnerColor | string \| GradientConfig | matches finderColor | Inner finder dot color | | logo | LogoConfig | - | Logo to embed in center | | overlayImage | OverlayImageConfig | - | Background overlay image | | halftone | HalftoneConfig | - | Halftone image effect | | margin | number | 4 | Quiet zone in modules | | marginColor | string | matches bgColor | Quiet zone color | | alignmentColor | string \| GradientConfig | matches fgColor | Alignment pattern color | | timingColor | string \| GradientConfig | matches fgColor | Timing pattern color | | frame | FrameConfig | - | Decorative frame with optional label | | preset | PresetName | - | Apply a style preset | | optimizeSvg | boolean | false | Merge adjacent modules for smaller SVG | | skipValidation | boolean | false | Skip contrast/size checks | | alt | string | 'QR Code' | Accessible label (aria-label) | | className | string | - | CSS class on wrapper div | | style | CSSProperties | - | Inline styles on wrapper div |

Related Packages

| Package | Description | |---------|-------------| | @qr-kit/core | QR generation engine (installed automatically) | | @qr-kit/dom | Vanilla JS renderer (installed automatically) |

License

MIT