qrcanvas
TypeScript icon, indicating that this package has built-in type declarations

3.1.2 • Public • Published

QRCanvas

NPM License Downloads

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.

Usage

With bundlers

Install as a dependency:

$ yarn add qrcanvas
# or 
$ npm install qrcanvas -S

Use as a module:

import { qrcanvas } from 'qrcanvas';
 
const canvas = qrcanvas({
  data: 'hello, world'
});
document.body.appendChild(canvas);

Browser

Load from CDN:

<div id="qrcode"></div>
 
<script src="https://cdn.jsdelivr.net/npm/qrcanvas@3"></script>

The module is mounted to a global variable named qrcanvas:

const canvas = qrcanvas.qrcanvas({
  data: 'hello, world'
});
document.getElementById('qrcode').appendChild(canvas);

Node.js

node-canvas is required in Node.js.

Install dependencies:

$ yarn add qrcanvas canvas
const fs = require('fs');
const { qrcanvas, setCanvasModule } = require('qrcanvas');
 
// Enable node-canvas
setCanvasModule(require('canvas'));
 
const canvas = qrcanvas({
  data: 'hello, world'
});
// canvas is an instance of `node-canvas`
canvas.pngStream().pipe(fs.createWriteStream('qrcode.png'));

Documents

Related

Snapshots

1

2

Readme

Keywords

none

Package Sidebar

Install

npm i qrcanvas

Weekly Downloads

739

Version

3.1.2

License

ISC

Unpacked Size

154 kB

Total Files

15

Last publish

Collaborators

  • gera2ld