JavaScript Navigator getVRDisplays() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Method

Definition

navigator.getVRDisplays() is a legacy WebVR method. MDN: it returns a Promise that resolves to an array of VRDisplay objects for available VR displays connected to the computer.

Pass the required arguments shown below. Check return values and browser support before you rely on the result.

Syntax

Call navigator.getVRDisplays. Start with this line.

JavaScript
navigator.getVRDisplays()
CallWhat it does
navigator.getVRDisplays()Primary signature.
navigator.getVRDisplays(...)Call with the arguments your case needs.

Built into the browser. Call getVRDisplays(...) on a Navigator — no import required.

Library declarations
JavaScript
navigator.getVRDisplays()

Parameters

This member has no parameters beyond those shown in the signature.

Return Value

Return ValueDescription
*Promise → VRDisplay[]

JavaScript Examples

Example 1 — Feature-Detect First

Most modern browsers omit WebVR. Check before calling.

JavaScript
const hasWebVR = typeof navigator.getVRDisplays === "function";
const hasWebXR = "xr" in navigator;

console.log("getVRDisplays:", hasWebVR ? "available" : "missing");
console.log("navigator.xr:", hasWebXR ? "available" : "missing");
Try It Yourself

How It Works

  1. Test the type so a missing method does not throw.
  2. Expect missing for WebVR on many modern browsers.
  3. Also check WebXR via "xr" in navigator.
  4. Literacy only — do not ship product logic on WebVR.

Example 2 — Await the Display List

MDN: the Promise resolves to a VRDisplay array (often empty).

JavaScript
async function listVrDisplays() {
  if (typeof navigator.getVRDisplays !== "function") {
    console.log("unsupported");
    return;
  }
  const displays = await navigator.getVRDisplays();
  console.log("count:", displays.length);
  displays.forEach(function (d, i) {
    console.log(i, d.displayName || d.displayId || "(unnamed)");
  });
}

listVrDisplays();
Try It Yourself

How It Works

  1. Guard first. Skip the call when the method is missing.
  2. Await the Promise. MDN: resolves to VRDisplay[].
  3. Empty is normal. No headset → length 0.
  4. Read names carefully. Properties vary by old implementations.

Example 3 — Prefer WebXR

MDN steers new immersive work to WebXR via navigator.xr.

JavaScript
async function checkImmersiveVr() {
  if (!navigator.xr) {
    console.log("WebXR missing — no immersive VR API here");
    return;
  }
  const ok = await navigator.xr.isSessionSupported("immersive-vr");
  console.log("immersive-vr supported:", ok);
}

checkImmersiveVr();
Try It Yourself

How It Works

  1. Use the modern entry. navigator.xr is WebXR’s gate.
  2. Ask about a mode. isSessionSupported("immersive-vr").
  3. Expect false often. Needs capable hardware / browser support.
  4. Frameworks help. A-Frame, Three.js, Babylon.js wrap WebXR.

Deprecated / Non-standard Support

navigator.getVRDisplays() is Deprecated and Non-standard on MDN. It belonged to old WebVR and is missing in most modern browsers. Prefer navigator.xr or a maintained XR framework.

✓ Deprecated · Non-standard

Navigator.getVRDisplays()

Promise → VRDisplay[] — legacy WebVR entry point. Literacy only.

Legacy Avoid in new code
Google Chrome WebVR removed — use WebXR
No
Microsoft Edge Prefer WebXR (Chromium)
No
Opera Prefer WebXR where available
No
Mozilla Firefox Legacy WebVR era ended
No
Apple Safari No WebVR getVRDisplays
No
Internet Explorer No WebVR / WebXR
No
getVRDisplays() Removed / rare

Bottom line: Do not ship new WebVR code. Feature-detect navigator.xr instead. See the MDN getVRDisplays() reference.

Frequently Asked Questions

MDN: it returns a Promise that resolves to an array of VRDisplay objects for available VR displays connected to the computer. It belonged to the old WebVR API.
Yes. MDN marks it Deprecated. WebVR development halted in favor of WebXR. Prefer navigator.xr or a maintained XR framework.
Yes. MDN also marks it Non-standard. WebVR never became a finished public web standard and was superseded by the WebXR Device API.
getVRDisplays() lists available VR displays. activeVRDisplays lists only displays that are currently presenting (isPresenting === true).
The WebXR Device API via navigator.xr (isSessionSupported / requestSession), or frameworks such as A-Frame, Three.js, or Babylon.js.
Usually the method is missing, or the Promise resolves to an empty array. That is expected without WebVR support and a headset.

Next: javaEnabled()

Continue with the next Navigator method in the tutorial series.

javaEnabled() →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

18 people found this page helpful