Detect XR Support with JavaScript


A few years ago I wrote an article about how to discover VR support with JavaScript. Since then, a whole lot has changed. “Augmented reality” became a thing and the terminology has moved to “XR”, instead of VR or AR. As such, the API has had to evolve.

The presence of navigator.xr signals that the browser supports the WebXR API and XR devices:

const supportsXR = 'xr' in window.navigator;

I really like to use in for function control instead if(navigator.xr), as mere invocation that could cause an initialization to take place. In future posts, we will explore identification and connection to various devices.

Website performance monitoring
Website performance monitoring
Website performance monitoring
Website performance monitoring
  • Create a CSS cube

    Create a CSS cube

    CSS Cubes really show what CSS has become over the years, evolving from simple color and dimension directives to a language capable of creating deep, creative visuals. Add animation and you have something really neat. Unfortunately, every CSS cube tutorial I’ve read is a bit…

  • 9 Mind-Blowing WebGL Demos

    9 Mind-Blowing WebGL Demos

    As much as developers now loathe Flash, we’re still catching up with it to replicate the animation capabilities that Adobe’s old technology gave us. Of course we have canvas, an amazing technology that I highlighted 9 amazing demos. Another technology available…

  • Creating spacers with Flexbox

    Creating spacers with Flexbox

    I was one of the biggest fans of flexbox before it hit, but due to being shuffled around at Mozilla, I never had the opportunity to use it in any practice project; therefore flexbox still seems a bit of a mystery to me. This largely…

  • Ana Tudor's favorite CodePen demos

    Ana Tudor’s favorite CodePen demos

    Cocoon I love canvas, I love interactive demos, and I don’t think I’ve ever been more impressed with anyone’s work than when I discovered what Tiffany Rayside has created on CodePen. So I had to start with one of her interactive canvas pens, although…

William

Leave a Reply

Your email address will not be published. Required fields are marked *