Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Pratyay360/upiqrcode/llms.txt

Use this file to discover all available pages before exploring further.

upiqrcode is a Rust library compiled to WebAssembly (WASM) that generates NPCI-compliant UPI payment QR codes as inline SVG strings, along with UPI intent URLs for deep-linking into payment apps. This page explains what the library does, how the Rust-to-WASM pipeline works, and what you need before you start.

What is upiqrcode?

upiqrcode is published to npm as upiqrcode (version 1.5.5). You import it like any other npm package and use it in React, Vue, Svelte, or plain JavaScript — no backend, no external API, and no payment gateway account required. When you call the main upiqrcode() function, you get back two things:
  • qr — a complete SVG string you can inject directly into the DOM as a scannable QR code
  • intent — a upi://pay? deep-link URL that opens a payment app on mobile devices
The library also exposes svg_qr_code(intent), a lower-level function that generates an SVG from any UPI intent URL string you already have.
upiqrcode v1.5.5 is available on npm. Install it with npm install upiqrcode.

How it works

upiqrcode is written in Rust and compiled to a .wasm binary using wasm-pack. The wasm-bindgen crate generates a JavaScript bridge so you can call the library’s functions as normal async JavaScript Promises — no manual WebAssembly instantiation required. The compilation pipeline looks like this: Because the library runs entirely inside the browser’s WASM runtime, all QR code generation happens on the client. No data ever leaves the user’s device. The async Promise API means you must call the default init() export once before using any other function. init() loads and compiles the .wasm binary asynchronously. After that, upiqrcode() and svg_qr_code() are ready to call.

Key features

SVG QR codes

Every QR code is returned as an inline SVG string — no image files, no CDN dependency, and no cross-origin requests. Inject it directly into the DOM with innerHTML.

UPI intent URLs

Alongside every QR code, you receive a upi://pay? deep-link URL. Use it as an href on mobile so users can tap to open Google Pay, PhonePe, Paytm, or BHIM instantly.

NPCI-compliant

The intent URL follows the official NPCI UPI deep link specification, including percent-encoding and support for all standard parameters such as pa, pn, am, cu, tr, and tn.

Zero backend

upiqrcode runs entirely in the browser. You do not need a server, an API key, or a payment processor account to generate QR codes.

The UPI ecosystem

UPI (Unified Payments Interface) is India’s real-time payment system, governed by the National Payments Corporation of India (NPCI). It lets users transfer money between bank accounts using a Virtual Payment Address (VPA) — a short identifier like name@bank — instead of sharing account numbers. A UPI intent URL (upi://pay?pa=...&pn=...) encodes the payment details and is understood by all BHIM-compatible apps, including:
  • Google Pay (GPay)
  • PhonePe
  • Paytm
  • BHIM (the NPCI reference app)
When a user scans the QR code or taps the intent link, their payment app opens pre-filled with the payee VPA, name, and amount. The user just confirms and pays.

Requirements

To use upiqrcode, you need:
  • A Node.js project managed with npm, yarn, or pnpm
  • A bundler that supports WebAssembly modules — Vite, webpack 5, Next.js (with the asyncWebAssembly experiment enabled), Rollup, or Parcel all work out of the box
upiqrcode targets the bundler WASM target, which means a build step is required. It does not currently support plain <script> tags without a bundler.

Build docs developers (and LLMs) love