A library for scanning QR codes on the web using a web worker.
Most of this code is taken directly from code-kotis/qr-code-scanner. I have only made minor modifications to it, mainly to make it more easily consumed as a library.
import { QRReader } from 'qr-reader'
const element = document.getElementById('video') // could also be an <img> element. If you're using react, you can use refs for this
// initialize the qr reader and web worker
const reader = new QRReader(element)
// scan the element
reader.scan(result => {
doSomethingWithQRText(result)
})
// terminate the web worker
reader.terminate()
If you find a bug, please file an issue. PR's are most welcome ;)