1.2.0 • Published 5 months ago

nodeqr v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

Introduction

NodeQR is a node module for anybody to be able to create programs with the ability to generate QR codes.

Module

To install NodeQR, run this command using npm (Node JS Package Manager):

npm install nodeqr

Intergration

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

1.2.0

5 months ago

1.1.0

5 months ago