Skip to content

chillerlan/js-qrcode

Repository files navigation

chillerlan/js-qrcode

A javascript port of chillerlan/php-qrcode, a QR Code library based on the implementation by Kazuhiko Arase.

License CodeCov Build

Documentation

An API documentation created with jsdoc can be found at https://chillerlan.github.io/js-qrcode/ (WIP).

Quickstart

Server-side, in nodejs:

import {QRCode} from './dist/js-qrcode-node-src.cjs';

let data   = 'otpauth://totp/test?secret=B3JX4VCVJDVNXNZ5&issuer=chillerlan.net';
let qrcode = (new QRCode()).render(data);

// do stuff
console.log(qrcode);

Client-side, in a webbrowser:

<div id="qrcode-container"></div>
<script type="module">
	import {QRCode} from './dist/js-qrcode-es6-src.js';
	
	// an SVG image as base64 data URI will be returned by default
	let qrcode = (new QRCode()).render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');

	// append it to the DOM
	let img = document.createElement('img');
	img.alt = 'QRCode';
	img.src = qrcode
	
	document.getElementById('qrcode-container').appendChild(img);
</script>

QR codes are awesome!

Have a look in the examples folder for some more usage examples.

License notice

Parts of this code are ported to js (via php) from the ZXing project and licensed under the Apache License, Version 2.0.

Trademark Notice

The word "QR Code" is a registered trademark of DENSO WAVE INCORPORATED
https://www.qrcode.com/en/faq.html#patentH2Title