We are trying to use lightning web component for a requirement in Salesforce where we try to capture the image of the user via webcam and this requirement is specifically for laptops and desktops. Below is how we were trying to access the webcam function

navigator.getMedia = ( navigator.getUserMedia ||
        navigator.webkitGetUserMedia ||
        navigator.mozGetUserMedia ||
                video: true,
                audio: false
            (stream) => {
                /* Capture the stream */
            (err) => {
                console.log("An error occured! " + err);

It seems the LWC compiler is not allowing navigator object to have getMedia function whereas with normal html and vanilla javascript we were able to do it.

Did anyone of you ever faced this scenario back and do we have a workaround as of now to fix this issue?


this is not a direct Web Component Issue. Most WebRTC Apis are not supported in Lockerservice which is enforced on all LWCs. The only "workaround" is to do it via an Aura Component nailed down to Api V.39, do it externally and embed it via lightning:container or do it via Visualforce (and iframing the page somewhere else if required).


| improve this answer | |
  • Thanks for the answer. Probably Salesforce enables these apis in lockerService in future – Karthick Shanmugam May 22 '19 at 22:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.