Secure context

This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The alpha property is a Boolean value which, if present and set to true in the XRWebGLLayerInit dictionary passed into the XRWebGLLayer() constructor, specifies that the new layer's color buffer is to include an alpha channel. Otherwise, the color buffer won't have an alpha channel. The default is true.


let layerInit = {
  alpha: boolValue
let glLayer = new XRWebGLLayer(xrSession, gl, layerInit);

let glLayer = new XRWebGLLayer(xrSession, gl, { alpha: boolValue });


A Boolean which can be set to true to request that the new WebGL layer for rendering the WebXR scene is to have an alpha channel.


In this example, a new XRWebGLLayer is created for a WebXR session, xrSession, without an alpha channel.

  baseLayer: new XRWebGLLayer(xrSession, gl, {
     alpha: false


WebXR Device API
# dom-xrwebgllayerinit-alpha

Browser compatibility

BCD tables only load in the browser

See also