Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-hook-qrcode

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-hook-qrcode

React hooks for generating QR code.

  • 1.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
80
decreased by-21.57%
Maintainers
1
Weekly downloads
 
Created
Source

react-hook-qrcode

React hooks for generating QR code.

NPM downloads npm bundle size Build Status JavaScript Style Guide

🎁 Features

  • Render as Canvas & Image
  • Support Numeric, Alphanumeric, Kanji and Byte mode
  • Support Japanese, Chinese, Greek and Cyrillic characters
  • Support multibyte characters (like emojis smile)

🔧 Install

react-hook-qrcode is available on npm. It can be installed with the following command:

npm install --save react-hook-qrcode

react-hook-qrcode is available on yarn as well. It can be installed with the following command:

yarn add react-hook-qrcode

💡 Canvas

usage

import React from 'react';
import { useQRCode } from 'react-hook-qrcode';

function App() {
  const [inputRef] = useQRCode({
    text: 'https://github.com/bunlong/react-hook-qrcode',
    options: {
      level: 'M',
      margin: 7,
      scale: 1,
      width: 200,
      color: {
        dark: '#010599FF',
        light: '#FFBF60FF'
      }
    }
  });
  
  return <canvas ref={inputRef} />;
};

export default App;

text

PropTypeRequireDescription
textstring✔️Text/URL to encode.
optionsoptionsQR code options.

options

PropTypeDefaultRequireDescription
levelstringMCorrection level. Possible values are low, medium, quartile, high or L, M, Q, H.
marginnumber4Define how much wide the quiet zone should be.
scalenumber4Scale factor. A value of 1 means 1px per modules (black dots).
widthnumber4Forces a specific width for the output image. If width is too small to contain the qr symbol, this option will be ignored. Takes precedence over scale.
color.darkstring#000000ffColor of dark module. Value must be in hex format (RGBA). Note: dark color should always be darker than color.light.
color.lightstring#ffffffffColor of light module. Value must be in hex format (RGBA).

💡 Image

usage

import React from 'react';
import { useQRCode } from 'react-hook-qrcode';

function App() {
  const [inputRef] = useQRCode({
    text: 'https://github.com/bunlong/react-hook-qrcode',
    options: {
      type: 'image/jpeg',
      quality: 0.3,
      level: 'M',
      margin: 3,
      scale: 4,
      width: 200,
      color: {
        dark: '#010599FF',
        light: '#FFBF60FF'
      }
    }
  });
  
  return <img ref={inputRef} />;
};

export default App;

text

PropTypeRequireDescription
textstring✔️Text/URL to encode.
optionsobjectQR code options

options

PropTypeDefaultRequireDescription
typestring (image/png, image/jpeg, image/webp)image/pngImage format.
qualitynumber0.92A Number between 0 and 1 indicating image quality if the type is image/jpeg or image/webp.
levelstringMCorrection level. Possible values are low, medium, quartile, high or L, M, Q, H.
marginnumber4Define how much wide the quiet zone should be.
scalenumber4Scale factor. A value of 1 means 1px per modules (black dots).
widthnumber4Forces a specific width for the output image. If width is too small to contain the qr symbol, this option will be ignored. Takes precedence over scale.
color.darkstring#000000ffColor of dark module. Value must be in hex format (RGBA). Note: dark color should always be darker than color.light.
color.lightstring#ffffffffColor of light module. Value must be in hex format (RGBA).

💖 Wrap Up

If you think any of the react-hook-qrcode can be improved, please do open a PR with any updates and submit any issues. Also, I will continue to improve this, so you might want to watch/star this repository to revisit.

🌟 Contribution

We'd love to have your helping hand on contributions to react-hook-qrcode by forking and sending a pull request!

Your contributions are heartily ♡ welcome, recognized and appreciated. (✿◠‿◠)

How to contribute:

  • Open pull request with improvements
  • Discuss ideas in issues
  • Spread the word
  • Reach out with any feedback

⚖️ License

The MIT License License: MIT

Keywords

FAQs

Package last updated on 14 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc