DEV Community

Sanchit Gupta
Sanchit Gupta

Posted on

Snippet... QR Code - Yes it's that easy to generate a QR Code

Image description

See it in Action : https://www.apps4developers.com/qr-code/

Installing qrcode

Install QrCode library from npm.

npm install qrcode
Enter fullscreen mode Exit fullscreen mode

Generate QR Code from String

import QRCode from 'qrcode';

QRCode.toDataURL(
  `https://www.apps4developers.com`,
  { margin: 2},
  function (err, url) {
    if (err) throw err;
   console.log(url);
  }
);

Enter fullscreen mode Exit fullscreen mode

Top comments (0)