Using Flash or Torch with Html5 QR code library

Minhaz
ScanApp
Published in
3 min readOct 30, 2022

--

Learn how to use torch with Javascript QR scanning library on Smartphones or enabling torch with camera in general using JS.

Photo by Gift Habeshaw on Pexels.

html5-qrcode is a fairly used open source library for implementing QR Code or Bar-Code scanner in a web application. It has 400K+ downloads on Github and going around 31K downloads/week on NPM.

I authored this library in my university days and have been maintaining this project since 2014 (If I remember correctly).

Enough bragging, coming back to the topic …

Almost all smartphones today come with camera which is coupled with a flash light. It’s also used as a torch while recording videos. Most QR scanning applications that are available on Android or IOS have support for enabling torch while scanning. This seems useful when scanning a code in low light conditions.

The feature request

There was a feature request on the project Github tracker for adding the same functionality to html5-qrcode library.

Since this is very interesting use-case — as it shows the power of web around controlling low level hardware on smartphones.

I decided to add support for this feature!

Support added for Html5QrcodeScanner

--

--

Minhaz
ScanApp

Staff Software Engineer @Google. Leading teams democratising On device AI for for masses. Writes about programming generics & specifics.