qrcode
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
dijkstrajs | 1.0.3 | 3.46 kB | MIT | prod | |
encode-utf8 | 1.0.3 | 1.75 kB | MIT | prod | |
pngjs | 5.0.0 | 195.46 kB | MIT | prod | |
yargs | 15.4.1 | 54.97 kB | MIT | prod |
QRCode is a powerful npm package that allows you to generate QR codes - 2D barcodes - that can be rendered on both the client and server sides using Node.js. It covers a plethora of options including support for numeric, alphanumeric, Kanji and Byte modes, mixed modes, and it even handles multibyte characters such as emojis. It supports error correction levels and QR code capacity with different symbol versions for optimal data compression and smallest QR code size.
To use QRCode in your JavaScript projects, you will first need to install it using npm with the following command:
npm install --save qrcode
After installation, you can start using it in your code. Here's an example of how you can generate a QR code using with QRCode:
var QRCode = require('qrcode')
QRCode.toDataURL('Your text here', function (err, url) {
console.log(url)
})
If you want to work with Promises or async/await, QRCode supports them too. Here's how you can use it with async/await:
import QRCode from 'qrcode'
const generateQR = async text => {
try {
console.log(await QRCode.toDataURL(text))
} catch (err) {
console.error(err)
}
}
generateQR('Your text here');
The comprehensive documentation for QRCode is included in the README file in the GitHub source code repository. The documentation covers several important topics including installation instructions, usage details, error correction levels, capacity of QR codes and encoding modes among others.