QRCanvas
This is a QRCode generator written in pure javascript.
Based on Kazuhiko Arase's QRCode.
The only requirement is that the browser works with a canvas
,
which is supported by most modern browsers.
Installation
$ npm i qrcanvas
Quick Start
-
Use in browser
You can either build the code or get released files from https://unpkg.com.
<div id="qrcode"></div> <script src="https://unpkg.com/qrcanvas"></script> <!-- A slim version is not bundled with any effects. --> <script src="https://unpkg.com/qrcanvas/dist/qrcanvas.slim.js"></script>
var canvas = qrcanvas({ data: 'hello, world' }); document.getElementById('qrcode').appendChild(canvas);
-
Use in Node.js
node-canvas is required in Node.js.
const fs = require('fs'); const qrcanvas = require('qrcanvas'); const canvas = qrcanvas({ data: 'hello, world' }); // canvas is an instance of `node-canvas` canvas.pngStream().pipe(fs.createWriteStream('qrcode.png'));