Monday, 2 January, 2023 UTC


Summary

A few years ago I wrote an article about how to detect VR support with JavaScript. Since that time, a whole lot has changed. “Augmented reality” became a thing and terminology has moved to “XR”, instead of VR or AR. As such, the API has needed 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 using in for feature checking rather than if(navigator.xr), as simply invoking that could cause some initialization to take place. In future posts we’ll explore identifying and connecting to different devices.
The post Detect XR Support with JavaScript appeared first on David Walsh Blog.