├── .babelrc
├── .eslintrc.js
├── .gitignore
├── .npmignore
├── .prettierrc
├── .travis.yml
├── CHANGELOG.md
├── CODE_OF_CONDUCT.md
├── LICENSE
├── README.md
├── jest.config.js
├── package.json
├── rollup.config.js
├── setup.ts
├── src
├── next-qrcode.ts
└── useQRCode.tsx
├── supports
├── create-next-app
│ ├── .eslintrc.json
│ ├── README.md
│ ├── next-env.d.ts
│ ├── next.config.js
│ ├── package.json
│ ├── src
│ │ └── app
│ │ │ ├── favicon.ico
│ │ │ ├── layout.tsx
│ │ │ └── page.tsx
│ └── tsconfig.json
└── create-react-app
│ ├── README.md
│ ├── package.json
│ ├── public
│ └── index.html
│ └── src
│ ├── App.js
│ ├── index.css
│ ├── index.js
│ ├── reportWebVitals.js
│ └── setupTests.js
├── tsconfig.jest.json
└── tsconfig.json
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | "@babel/preset-env",
4 | "@babel/preset-react"
5 | ] // ,
6 | // "plugins": ["@babel/plugin-proposal-class-properties"]
7 | }
8 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | parser: '@typescript-eslint/parser',
3 | extends: [
4 | 'plugin:@typescript-eslint/recommended',
5 | 'plugin:react/recommended',
6 | ],
7 | parserOptions: {
8 | ecmaVersion: 2018,
9 | sourceType: 'module',
10 | },
11 | plugins: ['react-hooks'],
12 | rules: {
13 | curly: 'error',
14 | '@typescript-eslint/indent': 'off',
15 | '@typescript-eslint/no-non-null-assertion': 'off',
16 | '@typescript-eslint/no-empty-function': 'off',
17 | '@typescript-eslint/ban-ts-comment': 'warn',
18 | '@typescript-eslint/no-explicit-any': 'off',
19 | '@typescript-eslint/explicit-function-return-type': 'off',
20 | '@typescript-eslint/no-empty-function': 'off',
21 | '@typescript-eslint/no-object-literal-type-assertion': 'off',
22 | 'react-hooks/rules-of-hooks': 'error',
23 | 'react-hooks/exhaustive-deps': 'error',
24 | 'react/display-name': 'warn',
25 | 'no-console': 'error',
26 | '@typescript-eslint/no-this-alias': [
27 | 'error',
28 | {
29 | 'allowDestructuring': true, // Allow `const { props, state } = this`; false by default
30 | 'allowedNames': ['self'] // Allow `const self = this`; `[]` by default
31 | }
32 | ],
33 | '@typescript-eslint/explicit-module-boundary-types': 'off',
34 | '@typescript-eslint/no-var-requires': 'off',
35 | },
36 | overrides: [
37 | {
38 | files: ['*.spec.ts', '*.spec.tsx'],
39 | rules: {
40 | // Allow testing runtime errors to suppress TS errors
41 | '@typescript-eslint/ban-ts-comment': 'off',
42 | '@typescript-eslint/explicit-module-boundary-types': 'off',
43 | },
44 | },
45 | ],
46 | settings: {
47 | react: {
48 | pragma: 'React',
49 | version: 'detect',
50 | },
51 | },
52 | };
53 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | node_modules
5 |
6 | # builds
7 | build
8 | dist
9 |
10 | # misc
11 | .DS_Store
12 | .env
13 | .env.local
14 | .env.development.local
15 | .env.test.local
16 | .env.production.local
17 |
18 | npm-debug.log*
19 | yarn-debug.log*
20 | yarn-error.log*
21 |
22 | package-lock.json
23 |
24 | /supports/create-react-app/node_modules
25 | /supports/create-react-app/package-lock.json
26 |
27 | /supports/create-next-app/node_modules
28 | /supports/create-next-app/.next
29 | /supports/create-next-app/package-lock.json
30 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | # ***
2 | # *
3 | # * https://docs.npmjs.com/cli/v6/using-npm/developers
4 | # *
5 | # ***
6 |
7 | /src
8 | /supports
9 | /test
10 | .gitignore
11 |
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "trailingComma": "all",
3 | "singleQuote": true
4 | }
5 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - 14
4 | - 13
5 | - 12
6 | - 11
7 | - 10
8 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## 2.5.1 (2023-08-01)
2 |
3 | ### ✨ Features
4 |
5 | * Upgrade QRCode options API
6 |
7 | Credits
8 |
9 | * [@Mehrdadx10](https://github.com/mehrdadx10)
10 |
11 | ## 2.5.0 (2023-07-05)
12 |
13 | ### ✨ Features
14 |
15 | * Upgrade dependencies
16 |
17 | Credits
18 |
19 | * [@Bunlong](https://github.com/Bunlong)
20 |
21 | ## 2.4.1 (2023-02-28)
22 |
23 | ### ✨ Features
24 |
25 | * Fix setting logo to center
26 |
27 | Credits
28 |
29 | * [@Bunlong](https://github.com/Bunlong)
30 |
31 | ## 2.4.0 (2022-11-29)
32 |
33 | ### ✨ Features
34 |
35 | * Add SVG
36 |
37 | Credits
38 |
39 | * [@Bunlong](https://github.com/Bunlong)
40 |
41 | ## 2.3.0 (2022-11-14)
42 |
43 | ### ✨ Features
44 |
45 | * Add logo to canvas
46 |
47 | Credits
48 |
49 | * [@Bunlong](https://github.com/Bunlong)
50 |
51 | ## 2.2.2 (2022-10-17)
52 |
53 | ### ✨ Features
54 |
55 | * Update dependencies
56 |
57 | Credits
58 |
59 | * [@Bunlong](https://github.com/Bunlong)
60 |
61 | ## 2.2.0 (2022-08-14)
62 |
63 | ### ✨ Features
64 |
65 | * Update dependencies
66 |
67 | Credits
68 |
69 | * [@Bunlong](https://github.com/Bunlong)
70 |
71 | ## 2.1.0 (2022-06-02)
72 |
73 | ### ✨ Features
74 |
75 | * Support React 18
76 |
77 | Credits
78 |
79 | * [@Bunlong](https://github.com/Bunlong)
80 |
81 | ## 2.0.0 (2022-02-02)
82 |
83 | ### ✨ Features
84 |
85 | * Improve code performance
86 | * Rewrite any existing hooks
87 |
88 | Credits
89 |
90 | * [@Bunlong](https://github.com/Bunlong)
91 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Code of Conduct
2 |
3 | Our open source projects are no exception. Trust, respect, collaboration and transparency are core values we believe should live and breathe within our projects. Our community welcomes participants from around the world with different experiences, unique perspectives, and great ideas to share.
4 |
5 | ## Our Pledge
6 |
7 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
8 |
9 | ## Our Standards
10 |
11 | Examples of behavior that contributes to creating a positive environment include:
12 |
13 | * Using welcoming and inclusive language
14 | * Being respectful of differing viewpoints and experiences
15 | * Gracefully accepting constructive criticism
16 | * Attempting collaboration before conflict
17 | * Focusing on what is best for the community
18 | * Showing empathy towards other community members
19 |
20 | Examples of unacceptable behavior by participants include:
21 |
22 | * Violence, threats of violence, or inciting others to commit self-harm
23 | * The use of sexualized language or imagery and unwelcome sexual attention or advances
24 | * Trolling, intentionally spreading misinformation, insulting/derogatory comments, and personal or political attacks
25 | * Public or private harassment
26 | * Publishing others' private information, such as a physical or electronic address, without explicit permission
27 | * Abuse of the reporting process to intentionally harass or exclude others
28 | * Advocating for, or encouraging, any of the above behavior
29 | * Other conduct which could reasonably be considered inappropriate in a professional setting
30 |
31 | ## Our Responsibilities
32 |
33 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
34 |
35 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
36 |
37 | ## Scope
38 |
39 | This Code of Conduct applies within all project spaces, and it also applies when an individual is representing the project or its community in public spaces. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
40 |
41 | ## Enforcement
42 |
43 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at `bunlong.van@gmail.com`. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
44 |
45 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
46 |
47 | ## Attribution
48 |
49 | This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 1.4, available at [https://www.contributor-covenant.org/version/1/4/code-of-conduct.html](https://www.contributor-covenant.org/version/1/4/code-of-conduct/)
50 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2020 Bunlong
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in
8 | all copies or substantial portions of the Software.
9 |
10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
11 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
13 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
14 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
15 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
16 | THE SOFTWARE.
17 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # next-qrcode
2 |
3 | React hooks for generating QR code for your next React apps.
4 |
5 | [](https://www.npmjs.com/package/next-qrcode) [](https://www.npmjs.com/package/next-qrcode)
6 |
7 | [](https://www.npmjs.com/package/next-qrcode)  [](https://standardjs.com)
8 |
9 | ## 🎁 Features
10 |
11 | * Render Canvas, SVG and Image
12 | * Support Numeric, Alphanumeric, Kanji and Byte mode
13 | * Support Japanese, Chinese, Greek and Cyrillic characters
14 | * Support multibyte characters (like emojis smile)
15 |
16 | [Live Demo](https://next-qrcode.js.org/demo)
17 |
18 | ## 🔧 Install
19 |
20 | next-qrcode is available on npm. It can be installed with the following command:
21 |
22 | ```js
23 | npm install next-qrcode --save
24 | ```
25 |
26 | next-qrcode is available on yarn as well. It can be installed with the following command:
27 |
28 | ```js
29 | yarn add next-qrcode --save
30 | ```
31 |
32 | ## 💡 Canvas
33 |
34 | ### Usage
35 |
36 | ```js
37 | import React from 'react';
38 | import { useQRCode } from 'next-qrcode';
39 |
40 | function App() {
41 | const { Canvas } = useQRCode();
42 |
43 | return (
44 |
57 | );
58 | }
59 |
60 | export default App;
61 | ```
62 |
63 | ### Canvas props
64 |
65 |
66 |
67 |
68 |
Prop
69 |
Type
70 |
Require
71 |
Description
72 |
73 |
74 |
75 |
76 |
text
77 |
string
78 |
✔️
79 |
Text/URL to encode.
80 |
81 |
82 |
options
83 |
options
84 |
❌
85 |
QR code options.
86 |
87 |
88 |
logo
89 |
logo
90 |
❌
91 |
QR code logo.
92 |
93 |
94 |
95 |
96 | ### options
97 |
98 |
99 |
100 |
101 |
Prop
102 |
Type
103 |
Default
104 |
Require
105 |
Description
106 |
107 |
108 |
109 |
110 |
errorCorrectionLevel
111 |
string
112 |
M
113 |
❌
114 |
Correction level. Possible values are low, medium, quartile, high or L, M, Q, H.
115 |
116 |
117 |
margin
118 |
number
119 |
4
120 |
❌
121 |
Define how much wide the quiet zone should be.
122 |
123 |
124 |
scale
125 |
number
126 |
4
127 |
❌
128 |
Scale factor. A value of 1 means 1px per modules (black dots).
129 |
130 |
131 |
width
132 |
number
133 |
4
134 |
❌
135 |
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.
136 |
137 |
138 |
color.dark
139 |
string
140 |
#000000ff
141 |
❌
142 |
Color of dark module. Value must be in hex format (RGBA). Note: dark color should always be darker than color.light.
143 |
144 |
145 |
color.light
146 |
string
147 |
#ffffffff
148 |
❌
149 |
Color of light module. Value must be in hex format (RGBA).
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.
300 |
301 |
302 |
color.dark
303 |
string
304 |
#000000ff
305 |
❌
306 |
Color of dark module. Value must be in hex format (RGBA). Note: dark color should always be darker than color.light.
307 |
308 |
309 |
color.light
310 |
string
311 |
#ffffffff
312 |
❌
313 |
Color of light module. Value must be in hex format (RGBA).
A Number between 0 and 1 indicating image quality if the type is image/jpeg or image/webp.
404 |
405 |
406 |
errorCorrectionLevel
407 |
string
408 |
M
409 |
❌
410 |
Correction level. Possible values are low, medium, quartile, high or L, M, Q, H.
411 |
412 |
413 |
margin
414 |
number
415 |
4
416 |
❌
417 |
Define how much wide the quiet zone should be.
418 |
419 |
420 |
scale
421 |
number
422 |
4
423 |
❌
424 |
Scale factor. A value of 1 means 1px per modules (black dots).
425 |
426 |
427 |
width
428 |
number
429 |
4
430 |
❌
431 |
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.
432 |
433 |
434 |
color.dark
435 |
string
436 |
#000000ff
437 |
❌
438 |
Color of dark module. Value must be in hex format (RGBA). Note: dark color should always be darker than color.light.
439 |
440 |
441 |
color.light
442 |
string
443 |
#ffffffff
444 |
❌
445 |
Color of light module. Value must be in hex format (RGBA).
446 |
447 |
448 |
449 |
450 | ## 📜 Changelog
451 |
452 | Latest version 2.5.1 (2023-08-01):
453 |
454 | * Upgrade QRCode options API
455 |
456 | Details changes for each release are documented in the [CHANGELOG.md](https://github.com/Bunlong/next-qrcode/blob/master/CHANGELOG.md).
457 |
458 | ## ❗ Issues
459 |
460 | 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.
461 |
462 | ## 🌟 Contribution
463 |
464 | We'd love to have your helping hand on contributions to `next-qrcode` by forking and sending a pull request!
465 |
466 | Your contributions are heartily ♡ welcome, recognized and appreciated. (✿◠‿◠)
467 |
468 | How to contribute:
469 |
470 | - Open pull request with improvements
471 | - Discuss ideas in issues
472 | - Spread the word
473 | - Reach out with any feedback
474 |
475 | ## 🏆 Contributors
476 |
477 |