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

@adityavijay21/upiqr

v1.0.0

Published

Generate NPCI's UPI QR code along with UPI intent link. Supports Node.js, browsers, and React Native.

Readme

@adityavijay21/upiqr: UPI QR Code Generator

npm version build status npm downloads license

A lightweight, modern, and customizable UPI QR code generator for Node.js, browsers, and React Native. Generate static and dynamic UPI QR codes with a simple, fluent API.


🌐 Live Demo

Test out the package in a live environment! The React demo app we built is a perfect showcase.

➡️ Launch the Live Demo (You can deploy the React demo to a service like Vercel or Netlify to get this link)


✨ Features

  • Fluent API: Easy-to-use, chainable methods for a clean development experience.
  • Framework Agnostic: Works in Node.js, browsers, React, Vue, Svelte, and more.
  • React Native Support: First-class support for React Native via SVG output.
  • Flexible Output: Generate QR codes as Base64 PNGs (dataURL), SVG strings, or UTF8 strings.
  • Fully Typed: Written in TypeScript for a great developer experience with autocompletion.
  • Easy Installation: No peer dependencies to manage. It just works.

⚙️ How It Works

The library simplifies the process of creating a valid UPI intent URL and encoding it into a QR code.

Your Data ➡️ UPIQR Class ➡️ UPI Intent String ➡️ QR Code


📦 Installation

npm install @adityavijay21/upiqr

🚀 Usage Examples

1. Basic Usage (Node.js or Browser)

Create a QR code with a fixed amount and a transaction note.

import { UPIQR } from '@adityavijay21/upiqr';

async function generate() {
  const { qr, intent } = await new UPIQR()
    .set({
      upiId: 'adityavijay21@okicici',
      name: 'Aditya Vijay',
      amount: 150.75,
      transactionNote: 'For the awesome project!',
    })
    .generate();
    
  // qr is a base64 PNG dataURL string that can be used in an <img> tag.
  console.log(qr);
}

generate();

2. Variable Amount (Static QR)

Omit the amount field to let the person paying enter the amount themselves.

import { UPIQR } from '@adityavijay21/upiqr';

const { qr } = await new UPIQR()
  .set({
    upiId: 'adityavijay21@okicici',
    name: 'Aditya Vijay',
    // No amount is specified
  })
  .generate();

3. React Example

A simple React component to display a generated QR code.

import React, { useState, useEffect } from 'react';
import { UPIQR } from '@adityavijay21/upiqr';

function PaymentQRCode() {
  const [qrCode, setQrCode] = useState('');
  
  useEffect(() => {
    async function getQRCode() {
      const { qr } = await new UPIQR()
        .set({
          upiId: 'shop@ybl',
          name: 'My Awesome Shop',
          amount: 250,
        })
        .generate();
      setQrCode(qr);
    };

    getQRCode();
  }, []);

  if (!qrCode) return <div>Loading...</div>;

  return <img src={qrCode} alt="UPI QR Code" />;
};

4. React Native Example (using SVG)

For React Native, generating an SVG is the best approach. You'll need react-native-svg.

import React, { useState, useEffect } from 'react';
import { View, Text } from 'react-native';
import { SvgXml } from 'react-native-svg';
import { UPIQR } from '@adityavijay21/upiqr';

function PaymentQRCodeNative() {
  const [qrSvg, setQrSvg] = useState(null);

  useEffect(() => {
    async function getQRCode() {
      const { qr } = await new UPIQR()
        .set({ upiId: 'shop@ybl', name: 'React Native Shop' })
        .setOptions({ outputType: 'svg' }) // Generate an SVG string
        .generate();
      setQrSvg(qr);
    };

    getQRCode();
  }, []);

  if (!qrSvg) return <Text>Loading QR Code...</Text>;

  return <SvgXml xml={qrSvg} width="250" height="250" />;
};

🛠️ API Reference

.set(params)

Sets the UPI payment parameters.

| Field | Type | Description | Required | | :--- | :--- | :--- | :--- | | upiId | String | The UPI ID of the payee (e.g., user@bank). | Yes | | name | String | The registered name of the payee. | Yes | | amount| Number | Amount to be paid. Omit for variable amount. | No | | payeeMerchantCode | String | Your Merchant Category Code. | No | | transactionId | String | A unique transaction ID for your reference. | No | | transactionRef | String | A reference ID for the transaction (e.g., Invoice #).| No | | transactionNote | String | A note for the payment (e.g., "Coffee Payment"). | No | | minimumAmount | Number | The minimum amount allowed for payment. | No | | currency | String | Currency code (defaults to INR). | No |

.setOptions(options)

Customizes the visual appearance of the generated QR code.

| Field | Type | Description | Default | | :--- | :--- | :--- | :--- | | outputType | 'dataURL', 'svg', 'utf8' | The desired output format of the QR code. | 'dataURL' | | width | Number | The width of the QR code image in pixels. | undefined | | margin | Number | The width of the quiet zone border. | 4 | | color.dark| String (Hex)| The color of the dark modules (e.g., #000000). | #000000FF| | color.light| String (Hex)| The color of the light modules (e.g., #FFFFFF). | #FFFFFFFF| | errorCorrectionLevel| 'L', 'M', 'Q', 'H' | The level of error correction. | 'M' |

.generate()

Generates the QR code.

  • Returns: Promise<UPIQRResult>
  • UPIQRResult is an object: { qr: string, intent: string }

🤝 Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page.

📄 License

This project is MIT licensed.