Create QR code on HTML canvas.
The main purpose of creating this library is learning TypeScript, different build tools and the QR code algorithm.
For production usage, please choose node-qrcode.
The original version is on legacy
branch, which was developed during an undergraduate web-developing course.
yarn add qr-ts
<body>
<div id="main"></div>
<script type="application/javascript" src="node_modules/qr-ts/dist/browser/index.js"></script>
<script>
const code = qr.renderOnCanvas(qr.generate("test"), "output");
const prev = document.getElementById("output");
if (prev != null) prev.replaceWith(code);
else document.getElementById("main").appendChild(code);
</script>
</body>
const qr = require("qr-ts");
// This prints out the instance of QR class, see docs for more info
console.log(qr.generate("test"));
run with node index.js
import * as qr from "qr-ts";
console.log(qr.generate("test")); // same as above
run with esm
or ts-node
i.e. node -r esm index.mjs
or ts-node index.ts