JavaScript Navigator hid Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Property

Definition

navigator.hid is a read-only property that returns an HID object — the entry point for the WebHID API (MDN). Use it to request HID devices and listen for connect/disconnect events.

Read the notes below before you rely on this property. Prefer feature detection when support is limited.

Syntax

Use navigator.hid. Start with this line.

JavaScript
navigator.hid
CallWhat it does
navigator.hidPrimary signature.

Built into the browser. Read navigator.hid on Navigator — no import required.

Library declarations
JavaScript
navigator.hid

Parameters

ParameterDescription
getDevices()Optional. List previously granted devices
FiltersOptional. Narrow picker by vendor/product/usage

Return Value

Return ValueDescription
*HID object

JavaScript Examples

Example 1 — Feature-Detect

Check whether WebHID is available before calling it.

JavaScript
const supported = "hid" in navigator;
console.log(supported ? "WebHID available" : "WebHID missing");
Try It Yourself

How It Works

  1. Use in. "hid" in navigator checks for the property.
  2. Expect limited support. Strongest historically in Chromium.
  3. Policy can hide it. Missing also means insecure page or blocked policy.
  4. Keep a fallback. Offer non-HID instructions when unsupported.

Example 2 — getDevices()

List HID devices this origin already has permission to use.

JavaScript
async function listKnown() {
  if (!("hid" in navigator)) {
    console.log("unsupported");
    return;
  }
  const devices = await navigator.hid.getDevices();
  console.log("known: " + devices.length);
  devices.forEach((d) => console.log("HID: " + d.productName));
}

listKnown();
Try It Yourself

How It Works

  1. Detect WebHID. Exit early when missing.
  2. Await getDevices(). Returns previously granted devices (MDN).
  3. Log the count. Often 0 until the user picks a device once.
  4. No picker here. Use requestDevice for first-time access.

Example 3 — requestDevice()

Open the device picker from a button click (transient user activation).

JavaScript
async function connectHid() {
  if (!("hid" in navigator)) {
    console.log("unsupported");
    return;
  }
  try {
    const devices = await navigator.hid.requestDevice({ filters: [] });
    if (!devices.length) {
      console.log("No device was selected.");
      return;
    }
    console.log("HID: " + devices[0].productName);
  } catch (err) {
    console.log("An error occurred.");
  }
}

document.querySelector("#connect").addEventListener("click", connectHid);
Try It Yourself

How It Works

  1. Wire a click handler. MDN requires transient user activation.
  2. Call requestDevice. Empty filters shows connected devices.
  3. Check the array. Empty means cancel; otherwise use devices[0].
  4. Catch errors. Security / gesture failures surface as exceptions.

Browser Support

Navigator.hid (WebHID) is Experimental and Limited availability (not Baseline) on MDN. It requires a secure context. Permissions Policy may hide the property.

✓ Experimental · Not Baseline

Navigator.hid

Support is strongest in Chromium-based browsers (Chrome, Edge, Opera). Firefox and Safari typically omit WebHID. Always feature-detect.

Limited Not Baseline
Google Chrome WebHID supported (secure context)
Supported
Microsoft Edge Chromium Edge — WebHID available
Supported
Opera Chromium-based — generally available
Supported
Mozilla Firefox Not typically available
Unavailable
Apple Safari Not typically available
Unavailable
navigator.hid Limited

Bottom line: Detect over HTTPS, request devices from a click, reuse getDevices() later, and keep a non-HID fallback.

Frequently Asked Questions

It is a read-only Navigator property that returns an HID object — the entry point for the WebHID API so your page can access HID devices and listen for connect/disconnect events (MDN).
Yes. MDN marks it Experimental and Limited availability (not Baseline). Always feature-detect and provide a non-HID fallback.
Yes. It is available only in secure contexts (HTTPS or localhost) in supporting browsers.
navigator.hid.requestDevice(options) opens the browser’s device picker so the user can grant access to a selected HID device. Call it from a user gesture such as a button click.
navigator.hid.getDevices() returns devices the user already granted access to earlier via requestDevice(). It does not show a new picker by itself.
Unsupported browser, insecure context, or a Permissions Policy that blocks WebHID — MDN notes the property will not be available when policy blocks usage.

Next: ink

Learn the navigator.ink entry for stylus and ink presentation.

ink tutorial →

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.

11 people found this page helpful