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 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-qr-code-gen

v1.0.1

Published

A versatile React wrapper around the `qrcode` package, allowing you to generate various types of QR codes with ease. This package supports URL, contact (vCard), app, SMS, email, phone, UPI, WiFi, location, and more QR code types, making it suitable for a

Downloads

28

Readme

QRCode Generator React Wrapper

A versatile React wrapper around the qrcode package, allowing you to generate various types of QR codes with ease. This package supports URL, contact (vCard), app, SMS, email, phone, UPI, WiFi, location, and more QR code types, making it suitable for a wide range of applications.

Features

  • Multiple QR Code Types: Supports generating QR codes for URLs, contacts, apps, SMS, emails, phones, UPI, WiFi networks, locations, and more.
  • Customizable Options: Customize the appearance of your QR codes with various options.
  • TypeScript Support: Includes TypeScript types for enhanced developer experience and type safety.
  • Lightweight: Designed to be minimal and efficient, perfect for modern React applications.
  • Error Handling: Built-in error handling during QR code generation.

Installation

To install the package, run:

npm install react-qrcode-generator

Or with Yarn:

yarn add react-qrcode-generator

Usage Below are examples of how to use the QRCode component for various types of QR codes.

Basic Usage

import React from 'react';
import { QRCode } from 'react-qrcode-generator';

function App() {
  return (
    <div>
      <h1>My QR Code</h1>
      <QRCode
        type="url"
        value={{ uri: "https://example.com" }}
        options={{ width: 200, margin: 2 }}
      />
    </div>
  );
}

export default App;

QR Code Types

URL QR Code

<QRCode type="url" value={{ uri: "https://example.com" }} />

Contact (vCard) QR Code

<QRCode
  type="contact"
  value={{
    firstname: "John",
    lastname: "Doe",
    organisation: "Example Corp",
    phoneNumber: "+1234567890",
    email: "[email protected]"
  }}
/>

Email QR Code

<QRCode
  type="email"
  value={{
    emailId: "[email protected]",
    subject: "Hello",
    message: "This is a test email."
  }}
/>

WiFi QR Code

<QRCode
  type="wifi"
  value={{
    ssid: "MyNetwork",
    networkType: "WPA",
    password: "password123"
  }}
/>

UPI QR Code

<QRCode
  type="upi"
  value={{
    upiId: "example@upi",
    payeeName: "John Doe",
    amount: 100.00,
    note: "Payment for services"
  }}
/>

Props

QRCode

| Prop | Type | Description | |----------|----------------------------------------------------------------------|-----------------------------------------------------------------------------------------------| | type | "url", "contact", "app", "sms", "email", "phone", "upi", "wifi", "location", "none" | Specifies the type of QR code to generate. | | value | Varies by type | The data to encode in the QR code. Must match the structure required by the specified type. | | options | QRCodeRenderersOptions (optional) | Customization options for the QR code appearance. |

QRCodeRenderersOptions

Refer to the qrcode documentation for available options.

Advanced Usage

Customizing the QR Code

You can customize the appearance of the QR code using the options prop:
<QRCode
  type="url"
  value={{ uri: "https://example.com" }}
  options={{
    width: 300,
    margin: 4,
    color: {
      dark: "#000000",
      light: "#ffffff"
    }
  }}
/>

Dynamic QR Code Content

The QR code will automatically update if the value or options props change:
import React, { useState } from 'react';
import { QRCode } from 'react-qrcode-generator';

function App() {
  const [url, setUrl] = useState("https://example.com");

  return (
    <div>
      <input
        type="text"
        value={url}
        onChange={(e) => setUrl(e.target.value)}
        placeholder="Enter a URL"
      />
      <QRCode type="url" value={{ uri: url }} />
    </div>
  );
}

export default App;

License

This project is licensed under the MIT License.

Contributing

Contributions are welcome! Please open an issue or submit a pull request if you have any improvements or new features to add.