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?

1 Answer 1


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).


  • Thanks for the answer. Probably Salesforce enables these apis in lockerService in future May 22, 2019 at 22:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .