Skip to main content
Using the Barcode Scanner API in Salesforce, is there a way to enable Torch for scanning during night time?

There doesn't seem to be an option for it in BarcodeScannerOptions.

I tried using an iframe to start video recording and enable the torch, but when starting the Barcode Scanner API, it seems to turn it off again automatically, before scanning.

A code sample of the API

 

const scanningOptions = {

barcodeTypes: [ scanner.barcodeTypes.EAN_13 ],

instructionText: 'Scan barcode',

successText: 'Scanning complete.'

};

const result = await scanner.beginCapture( scanningOptions );

4 answers
  1. Mar 30, 2025, 5:56 PM

    Currently, the Barcode Scanner API in LWC (Lightning Web Components) does not provide a built-in option to enable the torch (flashlight) during scanning. While this feature would be useful for scanning in low-light conditions, the API automatically manages the camera settings, and any external torch activation is typically overridden when the scanner starts.

    Some developers have attempted workarounds by using the device's camera through WebRTC to enable the torch before launching the scanner. However, this approach is not always reliable because the scanner API may reset the camera settings when activated. As of now, Salesforce has not officially provided a way to keep the torch on while scanning.

    If torch functionality is essential for your use case, you may consider submitting a feature request to Salesforce Support for future updates. Just like how customers look for flexibility in dairy queen menu prices canada, users of the Barcode Scanner API are also looking for more control over scanning conditions.

0/9000