Use this file to discover all available pages before exploring further.
In this quickstart you will install upiqrcode, initialize the WebAssembly module, call the upiqrcode() function with a payee VPA and name, and render the resulting SVG QR code and UPI intent URL in your project.
Always await init() before calling upiqrcode() or svg_qr_code(). The init() call loads the .wasm binary asynchronously and only needs to happen once per page load.
1
Install
Add upiqrcode to your project using your preferred package manager.
npm install upiqrcode
2
Initialize the WASM module
Import the default init export and call it once before using any other function. This loads and compiles the .wasm binary.
import init from "upiqrcode";await init();
You only need to call init() once per page load. After it resolves, the module is ready and subsequent calls to upiqrcode() are synchronous under the hood.
3
Generate a QR code
Call upiqrcode() with at least a payeeVPA and payeeName. The function returns a Promise that resolves to an object with two fields: qr (an SVG string) and intent (a upi://pay? URL).
import init, { upiqrcode, type UpiqrcodeResult } from "upiqrcode";await init();const result = (await upiqrcode({ payeeVPA: "example@upi", payeeName: "Jane Doe", amount: "250.00", transactionNote: "Payment for invoice #42",})) as UpiqrcodeResult;console.log(result.qr); // SVG markup stringconsole.log(result.intent); // upi://pay?pa=example%40upi&pn=Jane%20Doe&am=250.00&tn=Payment%20for%20invoice%20%2342
payeeVPA must be at least 5 characters and payeeName must be at least 4 characters. If either value is too short or missing, the Promise will reject with a validation error.
4
Display the result
Inject result.qr as innerHTML to render the QR code, and use result.intent as an href for a mobile payment button.
// Render the SVG QR codeconst container = document.getElementById("qr-container");if (container) { container.innerHTML = result.qr;}// Create a deep-link button for mobile usersconst payButton = document.getElementById("pay-button") as HTMLAnchorElement;if (payButton) { payButton.href = result.intent;}