🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

tinyqrc

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tinyqrc

A tiny QR code generator, written in TypeScript.

1.0.0
latest
Source
npm
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

TinyQRC

Introduction

TinyQRC is a lightweight and simple QR code generation library. Generate beautiful QR codes quickly and easily with zero dependencies.

Features

  • Fast & Lightweight - No dependencies, maximum performance
  • Simple API - Intuitive and easy to use
  • Customization - Control colors, size, and error correction levels
  • Type Safe - Written in TypeScript with full type support

Installation

npm install tinyqrc
# or
yarn add tinyqrc
# or
pnpm add tinyqrc
# or
bun add tinyqrc

Usage

import { generateSVG } from "tinyqrc";

// Generate a QR code
const svg = await generateSVG({
  value: "https://example.com",
  size: 256,
});

API Reference

generateSVG(options)

Generates a QR code as an SVG string.

type Options = {
  value: string; // Content to encode
  size?: number; // Size in pixels (default: 128)
  level?: "L" | "M" | "Q" | "H"; // Error correction level (default: "L")
  bgColor?: string; // Background color (default: "#FFFFFF")
  fgColor?: string; // Foreground color (default: "#000000")
  margin?: number; // Margin around QR code (default: 2)
  imageSettings?: {
    src: string; // URL of the image to embed
    height?: number; // Image height
    width?: number; // Image width
    x?: number; // X position
    y?: number; // Y position
    excavate?: boolean; // Whether to clear QR code modules under the image
  };
  // Any additional SVG attributes are passed through to the root SVG element
};

Error Correction Levels

  • L: Low (7% of data can be restored)
  • M: Medium (15% of data can be restored)
  • Q: Quartile (25% of data can be restored)
  • H: High (30% of data can be restored)

Note: When using imageSettings with excavate: true, the error correction level will automatically be increased to at least 'Q' to ensure better scannability.

Credits

Code Gen is based on nayuki/QR-Code-generator with modifications.

License

MIT License.

Keywords

qr

FAQs

Package last updated on 05 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts