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

@paymove-io/qr-generator

v1.9.4

Published

A modern, lightweight QR code generator with TypeScript support, offering SVG, PNG, and JPG output formats with customizable styling options.

Readme

paymove QR Generator

A modern, lightweight QR code generator with TypeScript support, offering SVG, PNG, and JPG output formats with customizable styling options.

🚀 Installation

npm install @paymove-io/qr-generator

📖 Basic Usage

Simple QR Code Generation

import { generateStyledQR } from "@paymove-io/qr-generator";

// Generate SVG (default format)
const svg = await generateStyledQR({
  data: "https://example.com",
  size: 300,
});

// Generate PNG
const png = await generateStyledQR({
  data: "https://example.com",
  format: "png",
  size: 512,
});

// Generate JPG
const jpg = await generateStyledQR({
  data: "https://example.com",
  format: "jpg",
  size: 512,
});

⚙️ Configuration Options

| Option | Type | Default | Description | | -------------------- | ------------------------- | ------- | ------------------------------------------- | | data | string | - | Required - Content to encode in QR code | | size | number | 300 | Output image size in pixels | | format | "svg" \| "png" \| "jpg" | "svg" | Output format | | withAdditionalData | boolean | false | Paymove logo and copy |

🎨 Advanced Features

Error Correction Levels

The library supports four error correction levels for robust QR codes:

  • L (Low): ~7% error correction
  • M (Medium): ~15% error correction
  • Q (Quartile): ~25% error correction
  • H (High): ~30% error correction (default)

Format-Specific Options

SVG Output

  • Vector-based, scalable format
  • Perfect for web applications
  • Smallest file size
  • No quality loss on scaling

PNG Output

  • High-quality bitmap format
  • Lossless compression
  • Ideal for printing and high-resolution displays
  • Default quality: 95%

JPG Output

  • Compressed bitmap format
  • Smaller file sizes
  • Good for web use
  • Default quality: 95%

🔧 Technical Details

Dependencies

  • QR Generation: qrcode-generator
  • Build Tool: tsup
  • Language: TypeScript

Cross-Platform Support

  • Browser: Uses native Canvas API
  • Node.js: Uses canvas package (optional dependency)

📱 Usage Examples

React/Next.js

import { useState } from "react";
import { generateStyledQR } from "@paymove-io/qr-generator";

function QRGenerator() {
  const [qrCode, setQrCode] = useState<string>("");

  const generateQR = async () => {
    try {
      const svg = await generateStyledQR({
        data: "https://paymove.io",
        size: 400,
        format: "svg",
      });
      setQrCode(svg as string);
    } catch (error) {
      console.error("Error generating QR:", error);
    }
  };

  return (
    <div>
      <button onClick={generateQR}>Generate QR Code</button>
      {qrCode && <div dangerouslySetInnerHTML={{ __html: qrCode }} />}
    </div>
  );
}

Node.js

import { generateStyledQR } from "@paymove-io/qr-generator";
import { writeFileSync } from "fs";

async function generateQRFile() {
  try {
    const pngBuffer = await generateStyledQR({
      data: "https://paymove.io",
      format: "png",
      size: 1024,
    });

    writeFileSync("qr-code.png", pngBuffer);
    console.log("QR code saved as qr-code.png");
  } catch (error) {
    console.error("Error:", error);
  }
}

Download QR Code in Browser

const downloadQR = async () => {
  try {
    const pngData = await generateStyledQR({
      data: "https://paymove.io",
      format: "png",
      size: 512,
    });

    // Create download link
    const blob = new Blob([pngData as string], { type: "image/png" });
    const url = URL.createObjectURL(blob);
    const a = document.createElement("a");
    a.href = url;
    a.download = "qr-code.png";
    a.click();
    URL.revokeObjectURL(url);
  } catch (error) {
    console.error("Error generating PNG:", error);
  }
};

🎯 Best Practices

For Web Applications

  • Use SVG format for responsive designs
  • Set appropriate size based on display context
  • Consider error correction level for your use case

For High-Quality Output

  • Use PNG format for printing
  • Set size to 2-3x the intended display size
  • Use H (High) error correction for maximum reliability

For File Size Optimization

  • Use JPG format for web
  • Consider reducing quality if acceptable
  • Balance between size and readability

🔍 Error Handling

The library provides clear error messages for common issues:

try {
  const qr = await generateStyledQR({
    data: "", // Empty data will throw error
    size: 100,
  });
} catch (error) {
  // Error: "options.data must be a non-empty string"
  console.error(error.message);
}

📄 License

ISC

🤝 Contributing

This is a TypeScript-based project. Please ensure all contributions include proper typing and follow the existing code structure.

📚 API Reference

generateStyledQR(options: QRStyleOptions): Promise<string | Buffer>

Main function that generates a QR code based on the provided options.

Returns:

  • string for SVG format
  • Buffer for PNG/JPG formats in Node.js
  • string (data URL) for PNG/JPG formats in browser

Throws:

  • Error for invalid data
  • Error for unsupported formats
  • Error for invalid size parameters