JSPM

qrcode-generator-sabai

1.1.6
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 8
  • Score
    100M100P100Q63674F
  • License MIT

qrcode-generator-sabai is a Node.js package designed to simplify QR code generation from various payloads to images. It offers ease of use and extensive customization options.

Package Exports

  • qrcode-generator-sabai
  • qrcode-generator-sabai/dist/index.js
  • qrcode-generator-sabai/dist/index.mjs

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (qrcode-generator-sabai) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

qrcode-generator-sabai

npm version npm License

⚠️ Important: This package is designed for server-side (Node.js) applications only and will not work in a browser environment.


Sample QR code

QR Code with Logo QR Code without Logo

Overview

qrcode-generator-sabai is a server-side Node.js package for generating QR codes in PNG, SVG, or Base64 formats with customization options such as size, error correction levels, and embedded logos.

📌 Server-Side Only

This package does NOT work in the browser because:

  • It uses Node.js file system (fs) to save QR codes as images.
  • It depends on server-side modules that are not available in browser environments.
  • If you need a frontend QR code generator, consider browser-compatible libraries like qrcode.

Use This Package For:

  • Backend APIs (e.g., Express.js, NestJS, Fastify)
  • Generating QR codes on the server and sending them to clients
  • Saving QR code images or Base64 data in databases or cloud storage

🚫 Do NOT Use This Package For:

  • Frontend/Browser apps (it will fail due to missing Node.js dependencies)

📌 Quick Start (Server-Side Usage)

const { QR } = require('qrcode-generator-sabai');

async function generateQRCode() {
    await QR.generate('https://github.com/iamlex01/qrcode-generator-sabai', {
        filePath: './public/images',
        fileName: 'qr-code.png'
    });
    console.log('QR Code saved successfully!');
}

generateQRCode().catch(console.error);

📖 Detailed Usage

1️⃣ Generate a PNG QR Code

const { QR } = require('qrcode-generator-sabai');

async function generateQRCode() {
    await QR.generate('https://example.com', {
        size: 300,
        errorCorrection: 'Q',
        format: 'png',
        filePath: './public/images',
        fileName: 'qr-code.png'
    });
    console.log('QR Code saved successfully!');
}

generateQRCode().catch(console.error);

2️⃣ Generate an SVG QR Code as a String

const { QR } = require('qrcode-generator-sabai');

async function generateQRCode() {
    const svgString = await QR.generate('https://example.com', {
        size: 400,
        errorCorrection: 'H',
        format: 'svg'
    });
    console.log('QR Code SVG:', svgString);
}

generateQRCode().catch(console.error);

3️⃣ Generate an SVG QR Code and Save as a File

const { QR } = require('qrcode-generator-sabai');

async function generateQRCode() {
    await QR.generate('https://example.com', {
        size: 400,
        errorCorrection: 'H',
        format: 'svg',
        filePath: './public/images',
        fileName: 'qr-code.svg'
    });
    console.log('QR Code SVG file saved successfully!');
}

generateQRCode().catch(console.error);

4️⃣ Generate a Base64 QR Code

const { QR } = require('qrcode-generator-sabai');

async function generateQRCode() {
    const base64 = await QR.generate('https://example.com', {
        size: 500,
        errorCorrection: 'M',
        format: 'base64'
    });
    console.log('QR Code Base64:', base64);
}

generateQRCode().catch(console.error);

const { QR } = require('qrcode-generator-sabai');

async function generateQRCode() {
    await QR.generate('https://example.com', {
        size: 400,
        logoPath: './logo.png', 
        format: 'png',
        filePath: './public/images',
        fileName: 'qr-code-logo.png'
    });
    console.log('PNG QR Code with logo generated!');
}

generateQRCode().catch(console.error);

const { QR } = require('qrcode-generator-sabai');

async function generateQRCode() {
    await QR.generate('https://example.com', {
        size: 400,
        logoPath: './logo.svg', 
        format: 'svg',
        filePath: './public/images',
        fileName: 'qr-code-logo.svg'
    });
    console.log('SVG QR Code with logo generated!');
}

generateQRCode().catch(console.error);

🎯 QR Code Options

Option Type Default Description
size number 200 QR code size in pixels (applies to PNG, SVG, and Base64).
errorCorrection 'L' | 'M' | 'Q' | 'H' 'M' Set the error correction level (applies to PNG, SVG, and Base64).
format 'png' | 'svg' | 'base64' 'png' Choose output format.
filePath string null Directory path to save the QR code file (only for png and svg).
fileName string null File name for the saved QR code (only for png and svg).
logoPath string null Path to an image file (PNG or SVG) to embed in the QR code (applies to png and svg).

🔄 Error Correction Levels

Level Error Resistance
L (Low) ~7%
M (Medium) ~15%
Q (Quartile) ~25%
H (High) ~30%

📜 License

qrcode-generator-sabai is licensed under the MIT License.