• Stars
    star
    159
  • Rank 235,916 (Top 5 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 4 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

React hooks for generating QRCode for your next React apps.

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

Prop Type Require Description
text string βœ”οΈ Text/URL to encode.
options options ❌ QR code options.
logo logo ❌ QR code logo.

options

Prop Type Default Require Description
errorCorrectionLevel 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).

logo

Prop Type Require Description
src string βœ”οΈ The path to the image.
options options ❌ Logo options.

options

Prop Type Default Require Description
width number ❌ Logo dimension.
x number ❌ If none or undefined, will center.
y number ❌ If 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

Prop Type Require Description
text string βœ”οΈ Text/URL to encode.
options options ❌ QR code options.

options

Prop Type Default Require Description
margin number 4 ❌ Define how much wide the quiet zone should be.
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,
        errorCorrectionLevel: 'M',
        margin: 3,
        scale: 4,
        width: 200,
        color: {
          dark: '#010599FF',
          light: '#FFBF60FF',
        },
      }}
    />
  );
}

export default App;

Image 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.
errorCorrectionLevel 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.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

More Repositories

1

react-papaparse

react-papaparse is the fastest in-browser CSV (or delimited text) parser for React. It is full of useful features such as CSVReader, CSVDownloader, readString, jsonToCSV, readRemoteFile, ... etc.
TypeScript
303
star
2

next-share

Social media share buttons for your next React apps.
TypeScript
162
star
3

react-native-custom-keyboard-kit

React Native Custom Keyboard - Use your own custom keyboard instead of the system keyboard with React Native Custom Keyboard Kit. Its working on Android and iOS.
Java
89
star
4

rails-livestamp

rails-livestamp is a simple jQuery plugin that provides auto-updating timeago text to your timestamped HTML elements.
Ruby
66
star
5

next-barcode

React hooks for generating Barcode for your next React apps.
JavaScript
57
star
6

react-screen-capture

A tiny React library allows you to take a snapshot of the webpage's screen or part of the screen.
TypeScript
34
star
7

The-Modern-JavaScript-Tutorial

Let learn JavaScript, starting from scratch and go on to advanced concepts.
25
star
8

react-native-csv

react-native-csv is the fastest CSV (or delimited text) parser for React Native.
Java
24
star
9

react-xls

react-xls is the fastest in-browser excel ( .xls & .xlsx ) parser for React. It is full of useful features such as useExcelDownloader, ... etc.
JavaScript
17
star
10

svelte-csv

svelte-csv is the fastest in-browser CSV (or delimited text) parser for Svelte. It is full of useful features such as CSVReader, CSVDownloader, readString, jsonToCSV, readRemoteFile, ... etc.
JavaScript
11
star
11

numer.js

An open-source JavaScript library for formatting and manipulating numbers.
JavaScript
11
star
12

git-commit-emoji

Git Commit Emoji is a standard of Emoji for using on Git commit messages.
11
star
13

react-webspeech

The official WebSpeech for React.
TypeScript
10
star
14

react-in-practice

Clear examples, explanations, and resources for React v.16.6.x (React Hooks)
10
star
15

react-hook-reading-time

Medium's like reading time estimation for React.
TypeScript
9
star
16

react-star

A tiny star rating component with custom icons for React.
TypeScript
9
star
17

libphonenumbers

JavaScript port of Google's libphonenumber library for parsing, formatting, and validating international phone numbers in Node.js.
JavaScript
7
star
18

react-flux-rails

react-flux-rails is a simple flux pattern javascript Gem for using in Rails framework.
Ruby
6
star
19

AI-learning

6
star
20

rails-social-share-button

rails-social-share-button is one of the best rails helper gem​ to add social share feature in your Rails app. Such as Twitter, Facebook, Tumblr, Weibo, Douban, QQ...
JavaScript
6
star
21

activenavbar

active navbar is used to set the active navbar link, a navbar link becomes active when you click on it.
Shell
5
star
22

react-catch-up

React Catch-up, React Changelog and all the new stuff.
5
star
23

next-faker

React hook for generating fake data for testing and development.
JavaScript
5
star
24

next-time-ago

A lightweight tiny time-ago component for your next React apps.
TypeScript
5
star
25

json-schema-relationships-links-vs-properties

Relationships definition for JSON Schema design.
5
star
26

node-package-cli

⚑ CLI for easily creating reusable node packages like react libraries and node libraries ⚑
JavaScript
4
star
27

create-svelte-library

πŸ“¦ CLI for creating reusable Svelte libraries.
JavaScript
4
star
28

github-auto-sync

JavaScript
4
star
29

strdash.js

An open-source JavaScript library for formatting and manipulating strings.
JavaScript
4
star
30

next-prism

A lightweight, robust, and elegant syntax highlighting component for your next React apps.
JavaScript
4
star
31

react-fullscreen-html

The React component allows its children to enter the browser's fullscreen viewing mode using the Fullscreen HTML5.
TypeScript
4
star
32

react-reading-time-estimator

Medium's like reading time estimator for React.
JavaScript
4
star
33

javascript-best-practices

JavaScript Best Practices
4
star
34

assets_helper

assets helper is the helper that use to include css and javascript by controller name automatically.
Shell
3
star
35

svelte-barcode

A light-weight and high-performance component to generate barcode for Svelte.
Svelte
3
star
36

Bunlong

About me.
3
star
37

react-layout-kit

JavaScript
3
star
38

react-native-star

A tiny star rating component with custom icons for React Native.
TypeScript
3
star
39

next-recaptcha

reCAPTCHA for your next React app.
TypeScript
3
star
40

facebook_auto_like

3
star
41

expressjs_memcached_mongodb_restful_api

Sample eXpressjs project using memcached and mongodb to build RESTful api for large project.
JavaScript
3
star
42

react-router-dom-redux-redux-thunk-redux-devtools

JavaScript
2
star
43

git-book

CSS
2
star
44

svelte-clock

An analog clock for your Svelte apps.
JavaScript
2
star
45

my-data-structures-and-algorithms

Learn data structures and algorithms.
Java
2
star
46

investigate-javascript-dom-and-vdom

Investigate Javascript DOM and Virtual DOM.
2
star
47

notify-on-rails

notify-on-rails is a simple standard Bootstrap alerts notifications.
Ruby
2
star
48

codervlog

I offer you some tips and tricks also some best practices of computer programming in simple way.
2
star
49

expressjs_memcached_mongodb_restful_api_upload_multi_images

JavaScript
2
star
50

travelling-salesman-problem-algorithm

2
star
51

docusaurus

Easy to Maintain Open Source Documentation Websites.
JavaScript
2
star
52

react-native-structure

react native directory structure.
JavaScript
2
star
53

brew-chain

JavaScript
2
star
54

erlang_pro

bunlong erlang algorithm
Erlang
1
star
55

songs_management

This web-based applications is developed using Gulpjs + Reactjs + ES7 + Ruby on Rails framework
JavaScript
1
star
56

chat

Sample Erlang Chat
JavaScript
1
star
57

typescript-in-practice

1
star
58

ruby_fast

Writing Ruby to be fast.
Ruby
1
star
59

all_about_layouts

Ruby
1
star
60

react-pdf-canvas

1
star
61

blog

The sample project that I focus on TDD testing using Rspec
Ruby
1
star
62

cake_cms

PHP
1
star
63

psc

PSC is a CLI tool for publishing a local file as a Bitbucket Snippet.
JavaScript
1
star
64

react-native-ar

Objective-C
1
star
65

expressjs_redis_jwt_restful_api

JavaScript
1
star
66

docker-compose-with-centos7-apache2-mysql5-php7

1
star
67

basic_chat_room

Reactjs + Socketio + ExpressJs, Nodejs
JavaScript
1
star
68

bunlong.github.io

CSS
1
star
69

fetch

TypeScript
1
star
70

bunlong-github

JavaScript
1
star
71

olive

Olive is the rails helper​ gem that enables to use content_for in controllers.
Shell
1
star
72

vagrant-centos-and-ubuntu-on-ubuntu

PHP
1
star