This guide walks you through integratingDocumentation 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 into a React application. Because upiqrcode is compiled to WebAssembly, you need to initialize the WASM module before calling any of its functions — this guide shows you exactly how to do that with useEffect and how to manage loading, error, and result states cleanly.
Prerequisites: React 18 or later, a bundler with WASM support (Vite is recommended), and
upiqrcode installed in your project.Vite configuration
If you are using Vite, add the following option tovite.config.ts to prevent Vite from pre-bundling the WASM package, which would break the module:
vite.config.ts
Steps
Create the component
Create a new file The
UPIQRCode.tsx and set up state for the QR SVG, the intent URL, a loading flag, and an error message:UPIQRCode.tsx
init() call loads the WASM binary. You must await it before calling upiqrcode(). Placing both inside useEffect ensures the WASM module is only loaded in the browser, not during server-side rendering.Add error handling
The
try/catch block above already captures errors from both init() and upiqrcode(). Validation errors — such as a payeeVPA shorter than 5 characters or a payeeName shorter than 4 characters — are thrown as strings and surfaced through the error state:Using the component
Import and renderUPIQRCode anywhere in your app. Pass at minimum a payeeVPA and payeeName:
App.tsx
Mobile deep link button
On a mobile browser, theupi:// intent URL opens the device’s default UPI payment app directly. You can style the link as a button to make it more prominent:
Next steps
API reference: upiqrcode()
See the full parameter reference, return type, and validation rules for the
upiqrcode function.