Socket
Socket
Sign inDemoInstall

next-qrcode

Package Overview
Dependencies
33
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    next-qrcode

React hooks for generating QR code for your next React apps.


Version published
Weekly downloads
84K
increased by9.41%
Maintainers
1
Install size
1.65 MB
Created
Weekly downloads
 

Changelog

Source

2.5.1 (2023-08-01)

✨ Features

  • Upgrade QRCode options API

Credits

  • @Mehrdadx10

Readme

Source

next-qrcode

React hooks for generating QR code for your next React apps.

downloads downloads

NPM npm bundle size JavaScript Style Guide

🎁 Features

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

Live Demo

🔧 Install

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

npm install next-qrcode --save

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

yarn add next-qrcode --save

💡 Canvas

Usage

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

function App() {
  const { Canvas } = useQRCode();

  return (
    <Canvas
      text={'https://github.com/bunlong/next-qrcode'}
      options={{
        errorCorrectionLevel: 'M',
        margin: 3,
        scale: 4,
        width: 200,
        color: {
          dark: '#010599FF',
          light: '#FFBF60FF',
        },
      }}
    />
  );
}

export default App;

Canvas props

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

options

PropTypeDefaultRequireDescription
errorCorrectionLevelstringMCorrection 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).
PropTypeRequireDescription
srcstring✔️The path to the image.
optionsoptionsLogo options.

options

PropTypeDefaultRequireDescription
widthnumberLogo dimension.
xnumberIf none or undefined, will center.
ynumberIf none or undefined, will center.

💡 SVG

Usage

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

function App() {
  const { SVG } = useQRCode();

  return (
    <SVG
      text={'https://github.com/bunlong/next-qrcode'}
      options={{
        margin: 2,
        width: 200,
        color: {
          dark: '#010599FF',
          light: '#FFBF60FF',
        },
      }}
    />
  );
}

export default App;

SVG props

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

options

PropTypeDefaultRequireDescription
marginnumber4Define how much wide the quiet zone should be.
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 'next-qrcode';

function App() {
  const { Image } = useQRCode();

  return (
    <Image
      text={'https://github.com/bunlong/next-qrcode'}
      options={{
        type: 'image/jpeg',
        quality: 0.3,
        errorCorrectionLevel: 'M',
        margin: 3,
        scale: 4,
        width: 200,
        color: {
          dark: '#010599FF',
          light: '#FFBF60FF',
        },
      }}
    />
  );
}

export default App;

Image props

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.
errorCorrectionLevelstringMCorrection 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).

📜 Changelog

Latest version 2.5.1 (2023-08-01):

  • Upgrade QRCode options API

Details changes for each release are documented in the CHANGELOG.md.

❗ Issues

If you think any of the next-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 next-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

🏆 Contributors

Bunlong
Bunlong
Michael Desa
Michael Desa
Jared Scheib
Jared Scheib
Mehrdad MotaghiFar
Mehrdad MotaghiFar

👨‍👩‍👦 Advertisement

You maybe interested.

  • React Patterns – React patterns & techniques to use in development for React Developer.
  • React Papaparse – The fastest in-browser CSV (or delimited text) parser for React.
  • Next Share – Social media share buttons for your next React apps.
  • Next Time Ago – A lightweight tiny time-ago component for your next React apps.

⚖️ License

The MIT License License: MIT

Keywords

FAQs

Last updated on 02 Aug 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc