Git Product home page Git Product logo

next-qrcode's Introduction

next-qrcode

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

downloads

NPM npm bundle size JavaScript Style Guide

๐ŸŽ Features

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

๐Ÿ”ง 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

๐Ÿ’ก 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={{
        type: 'image/jpeg',
        quality: 0.3,
        level: 'M',
        margin: 3,
        scale: 4,
        width: 200,
        color: {
          dark: '#010599FF',
          light: '#FFBF60FF',
        },
      }}
    />
  );
}

export default App;

props

Prop Type Require Description
text string โœ”๏ธ Text/URL to encode.
options options โŒ QR code options.

options

Prop Type Default Require Description
level string M โŒ Correction level. Possible values are low, medium, quartile, high or L, M, Q, H.
margin number 4 โŒ Define how much wide the quiet zone should be.
scale number 4 โŒ Scale factor. A value of 1 means 1px per modules (black dots).
width number 4 โŒ Forces 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.dark string #000000ff โŒ Color of dark module. Value must be in hex format (RGBA). Note: dark color should always be darker than color.light.
color.light string #ffffffff โŒ Color 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,
        level: 'M',
        margin: 3,
        scale: 4,
        width: 200,
        color: {
          dark: '#010599FF',
          light: '#FFBF60FF',
        },
      }}
    />
  );
}

export default App;

props

Prop Type Require Description
text string โœ”๏ธ Text/URL to encode.
options object โŒ QR code options

options

Prop Type Default Require Description
type string (image/png, image/jpeg, image/webp) image/png โŒ Image format.
quality number 0.92 โŒ A Number between 0 and 1 indicating image quality if the type is image/jpeg or image/webp.
level string M โŒ Correction level. Possible values are low, medium, quartile, high or L, M, Q, H.
margin number 4 โŒ Define how much wide the quiet zone should be.
scale number 4 โŒ Scale factor. A value of 1 means 1px per modules (black dots).
width number 4 โŒ Forces 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.dark string #000000ff โŒ Color of dark module. Value must be in hex format (RGBA). Note: dark color should always be darker than color.light.
color.light string #ffffffff โŒ Color of light module. Value must be in hex format (RGBA).

๐Ÿ“œ Changelog

Latest version 2.0.0 (2022-02-02):

  • Improve code performance
  • Rewrite any existing hooks

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

๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘ฆ Advertisement

You maybe interested.

  • React Patterns โ€“ React patterns & techniques to use in development for React Developer.
  • React Patterns Blog โ€“ The latest React news and articles.
  • React Papaparse โ€“ The fastest in-browser CSV (or delimited text) parser for React.
  • Next Share โ€“ Social media share buttons for your next React apps.

โš–๏ธ License

The MIT License License: MIT

next-qrcode's People

Contributors

bunlong avatar jaredscheib avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.