navigator.hid is the entry point for the WebHID API. Learn the HID object, requestDevice / getDevices, connect events, secure context rules, five examples, and try-it labs.
01
Kind
Read-only property
02
Returns
HID object
03
Status
Experimental
04
Context
Secure (HTTPS)
05
Pick device
requestDevice()
06
Reuse
getDevices()
Fundamentals
Introduction
HID means Human Interface Device — keyboards, gamepads, special USB gadgets, and many custom controllers speak the HID protocol. WebHID lets a web page talk to those devices (with the user’s permission).
navigator.hid is read-only. When WebHID is available, it returns an HID object you use to request access, list previously allowed devices, and listen for connect / disconnect events.
💡
Permission first
You cannot silently open every USB gadget on the user’s desk. requestDevice() shows a picker and needs a user gesture (button click). Always explain why you need the device.
Concept
Understanding the hid Property
Think of navigator.hid as the WebHID “front desk.” The real work happens on the HID object it returns.
HID object — entry point with methods and events.
requestDevice() — user picks a device and grants access.
getDevices() — list devices already granted earlier.
connect / disconnect — events when devices appear or leave.
Permissions Policy — if blocked, navigator.hid may be missing entirely.
Foundation
📝 Syntax
General form of the property:
JavaScript
navigator.hid
Value
An HID object when WebHID is available in this context.
Missing / unavailable when unsupported, insecure, or blocked by policy.
Common patterns
JavaScript
// Feature-detect:
if ("hid" in navigator && navigator.hid) {
// WebHID entry point is available
}
// Request a device (must run from a click handler):
async function pickDevice() {
const devices = await navigator.hid.requestDevice({
filters: [] // empty = show more devices; prefer real vendor/product filters
});
console.log(devices);
}
// List previously granted devices:
const known = await navigator.hid.getDevices();
Cheat Sheet
⚡ Quick Reference
Goal
Code
Get WebHID entry
navigator.hid
Detect API
"hid" in navigator && navigator.hid
Pick a device
await navigator.hid.requestDevice({ filters })
List granted devices
await navigator.hid.getDevices()
Listen for plug-in
navigator.hid.addEventListener("connect", …)
Secure page?
window.isSecureContext
Status (MDN)
Experimental / not Baseline
Snapshot
🔍 At a Glance
Four facts to remember about navigator.hid.
Returns
HID
WebHID entry
Status
experimental
Not Baseline
HTTPS
required
Secure context
Permission
user gesture
requestDevice
Compare
📋 WebHID vs WebUSB (concept)
WebHID (navigator.hid)
WebUSB (typical)
Focus
HID-class devices (reports / collections)
Broader USB device access
Entry
navigator.hid
navigator.usb
Permission
requestDevice() picker
Similar user-granted picker
Best for
Gamepads, specialty HID gadgets
Custom USB protocols
Status
Experimental / limited
Also limited — check MDN
Hands-On
Examples Gallery
Examples follow MDN WebHID / navigator.hid patterns. Prefer Try It Yourself on HTTPS in a Chromium browser with a real HID device. requestDevice needs a button click.
📚 Getting Started
Detect WebHID and confirm a secure context.
Example 1 — Feature Detection
Check whether the WebHID entry point exists on navigator.
WebHID missing
(or "WebHID available" in a supporting browser)
How It Works
If missing, show a message and keep a non-HID path (manual setup, native app, etc.).
Example 2 — Secure Context Check
WebHID requires HTTPS / localhost — check both flags together.
JavaScript
console.log("secure: " + window.isSecureContext);
console.log("hid: " + Boolean(navigator.hid));
if (!window.isSecureContext) {
console.log("Serve over HTTPS to use WebHID");
} else if (!navigator.hid) {
console.log("Secure, but WebHID not exposed");
} else {
console.log("Ready to call getDevices / requestDevice");
}
navigator.hid (WebHID) is Experimental and not Baseline. Availability is limited — historically strongest in Chromium. Always feature-detect, require HTTPS, and keep a fallback.
✓ Experimental · Not Baseline
Navigator.hid
Entry point for WebHID. Detect the HID object, request devices from a user gesture, and listen for connect/disconnect.
LimitedNot Baseline
Google ChromeWebHID supported in recent desktop Chrome (secure context)
Supported*
Microsoft EdgeChromium Edge — follows Chrome WebHID support
Supported*
OperaChromium-based — WebHID where Chromium enables it
Supported*
Mozilla FirefoxNot available for typical web content — check current MDN
Unavailable
Apple SafariNot available for typical web content — check current MDN
Unavailable
hidLimited
Bottom line: Detect WebHID over HTTPS, call requestDevice from a click, and never require HID for core site features.
Wrap Up
Conclusion
navigator.hid is the WebHID entry point. Feature-detect it in a secure context, call requestDevice() from a button click, reuse access with getDevices(), and listen for connect / disconnect when you need live plug events.
Use vendor/product filters when you know the device
Provide a clear non-HID fallback
❌ Don’t
Assume Safari/Firefox expose WebHID
Call the picker on page load
Require HID for essential site features
Ignore Permissions Policy / iframe restrictions
Skip explaining why you need the device
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about hid
Experimental WebHID entry — detect, ask, then talk to the device.
5
Core concepts
💻01
Returns
HID object
Entry
🔒02
HTTPS
Secure context
Required
🔑03
Pick
requestDevice
Gesture
📋04
Reuse
getDevices
Granted
🔬05
Status
Experimental
Detect
❓ 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 device connections and listen for connect/disconnect events.
Yes. MDN marks it Experimental and not Baseline. Support is limited (historically strongest in Chromium). 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. It resolves to an array of HIDDevice objects.
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.
Did you know?
MDN warns that when a Permissions Policy blocks WebHID, Navigator.hid is simply not available — your feature-detect should treat that the same as “unsupported.”