NodeQR is a node module for anybody to be able to create programs with the ability to generate QR codes.
To install NodeQR, run this command using npm
(Node JS Package Manager):
npm install nodeqr
After installing the module, call on the module using import
or require
and initialize the class QRCode
to create one. Here is an example using HTML and JavaScript:
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>QRCode Testing</title>
<script src="./script.js"></script>
</head>
<body>
<img id="qrcode-container">
</body>
</html>
JavaScript:
const nodeqr = require('nodeqr');
function generateQRCode(data, containerId) {
var qrcode = new nodeqr.QRCode(0, QRCode.ErrorCorrectLevel.L);
qrcode.addData(data);
qrcode.make();
var container = document.getElementById(containerId);
var qrCodeElement = qrcode.createImgTag(4, 0);
container.innerHTML = qrCodeElement;
}
document.addEventListener("DOMContentLoaded", function () {
var dataToEncode = "https://www.example.com";
var containerId = "qrcode-container";
generateQRCode(dataToEncode, containerId);
});
Now you can create a QR code by changing the link to the target URL of your choice.
This module is completely free-to-use by anybody to integrate the amazing and magical ability of QR codes to anything