← Chrome 158 reference · All APIs
v158 · device · enabled by default
Support for WebHID
Chrome 158 brings the WebHID API to Chrome on Android (requiring Android 17 / API level 37 or later) with no changes to the web-exposed API surface. Web applications on Android can now request permission to connect to USB and Bluetooth Human Interface Devices (HIDs), inspect report descriptors, and exchange input, output, and feature reports using the same navigator.hid, HID, and HIDDevice contracts that shipped on desktop Chrome in version 89. Android WebView remains unsupported.
at a glance
| Shipped in | Chrome 158 on Android (enabled by default; requires Android 17 / API level 37 or later) — filed under “Enabled by default” in the milestone=158 listing. Desktop platforms (Windows, macOS, Linux, ChromeOS) shipped in Chrome 89. Android WebView is not supported. |
|---|---|
| Origin trial / flag | Developer trial on Android began in Chrome 154 behind chrome://flags/#web-hid-on-android (about_flags.cc mapping to blink::features::kWebHID); desktop origin trial ran in Chrome 86–88. Enabled by default in Chrome 158 via WebHID runtime flag (status: "stable"). |
| Permissions Policy | hid — default allowlist 'self' (Chromium permissions_policy_features.json5; WHATWG HID §Permissions Policy) |
| Specification | WebHID API Living Standard (WHATWG) |
| Explainer | whatwg/hid EXPLAINER.md |
| Intent | blink-dev Intent to Ship (Android, Chrome 158); blink-dev Intent to Ship (Desktop, Chrome 89) |
| Tracking bug | crbug.com/40628009 (WebHID on Android); crbug.com/40163407 (Android WebView) |
| Web platform tests | wpt.fyi/results/webhid (IDL exposure and permissions policy; hardware I/O and Android chooser UI are tested in Chromium internal tests) |
| ChromeStatus | 5172464636133376 — Support for WebHID |
why it exists
Human Interface Devices (HIDs) cover far more than standard keyboards, mice, and gamepads: programmable mechanical keyboards, macro keypads, gaming mice with custom DPI/RGB firmware, barcode scanners, Braille displays, and USB/Bluetooth call-center headsets all expose vendor-specific HID collections that OS input layers do not map to standard web events. Desktop Chrome has supported WebHID since Chrome 89, but Android lacked the underlying platform HID enumeration and report-I/O APIs needed to expose those devices safely to Chrome.
Android 17 (API level 37) introduces native platform HID support via android.hardware.hid.HidDevice, enabling Chrome 158 on Android to expose the exact same WebHID API surface over USB and Bluetooth without requiring app developers to rewrite existing desktop WebHID web applications.
hid_service_android.cc; whatwg/hid explainer.
Syntax
Chrome 158 introduces no new WebIDL members; Chrome on Android exposes the existing WHATWG WebHID Living Standard interfaces verbatim (matching Chromium’s hid.idl, hid_device.idl, navigator_hid.idl, and worker_navigator_hid.idl):
[SecureContext] partial interface Navigator {
[SameObject] readonly attribute HID hid;
};
[Exposed=(DedicatedWorker,ServiceWorker), SecureContext]
partial interface WorkerNavigator {
[SameObject] readonly attribute HID hid;
};
[Exposed=(DedicatedWorker,ServiceWorker,Window), SecureContext]
interface HID : EventTarget {
attribute EventHandler onconnect;
attribute EventHandler ondisconnect;
Promise<sequence<HIDDevice>> getDevices();
[Exposed=Window] Promise<sequence<HIDDevice>> requestDevice(
HIDDeviceRequestOptions options
);
};
dictionary HIDDeviceRequestOptions {
required sequence<HIDDeviceFilter> filters;
sequence<HIDDeviceFilter> exclusionFilters;
};
dictionary HIDDeviceFilter {
unsigned short vendorId;
unsigned short productId;
unsigned short usagePage;
unsigned short usage;
};
[Exposed=(DedicatedWorker,ServiceWorker,Window), SecureContext]
interface HIDDevice : EventTarget {
attribute EventHandler oninputreport;
readonly attribute boolean opened;
readonly attribute unsigned short vendorId;
readonly attribute unsigned short productId;
readonly attribute DOMString productName;
readonly attribute FrozenArray<HIDCollectionInfo> collections;
Promise<undefined> open();
Promise<undefined> close();
Promise<undefined> forget();
Promise<undefined> sendReport([EnforceRange] octet reportId, BufferSource data);
Promise<undefined> sendFeatureReport([EnforceRange] octet reportId, BufferSource data);
Promise<DataView> receiveFeatureReport([EnforceRange] octet reportId);
};
[Exposed=(DedicatedWorker,ServiceWorker,Window), SecureContext]
interface HIDConnectionEvent : Event {
constructor(DOMString type, HIDConnectionEventInit eventInitDict);
[SameObject] readonly attribute HIDDevice device;
};
[Exposed=(DedicatedWorker,ServiceWorker,Window), SecureContext]
interface HIDInputReportEvent : Event {
constructor(DOMString type, HIDInputReportEventInit eventInitDict);
[SameObject] readonly attribute HIDDevice device;
readonly attribute octet reportId;
readonly attribute DataView data;
};
This reference covers four parts of the contract: navigator.hid and HID enumeration, HIDDevice lifecycle and report I/O, events and report descriptor dictionaries, and Chrome 158 Android 17+ platform behavior and enterprise policies.
hid.idl; Blink hid_device.idl.
navigator.hid and HID — device discovery and permission
Inputs. navigator.hid.getDevices() takes no arguments. navigator.hid.requestDevice(options) requires a HIDDeviceRequestOptions dictionary with a required filters sequence (pass { filters: [] } to show all non-blocklisted devices) and an optional exclusionFilters sequence (which, if provided, must contain at least one filter). Each HIDDeviceFilter accepts unsigned 16-bit integers: vendorId, productId (only valid if vendorId is also set), usagePage, and usage (only valid if usagePage is also set). A device matches if it satisfies at least one entry in filters (or filters is empty) and does not match any entry in exclusionFilters.
Outputs. Both getDevices() and requestDevice(options) return a Promise<HIDDevice[]>. getDevices() resolves to all currently connected devices to which the origin already holds permission. requestDevice(options) displays the browser’s native device chooser UI (on Android, the Chrome device-chooser prompt) and resolves to the array of user-selected HIDDevice objects (an empty array if the user cancels the chooser). A single physical peripheral exposing multiple top-level HID interfaces can appear as multiple logical HIDDevice instances.
hid.cc.
HIDDevice — connection lifecycle and report I/O
Inputs. open(), close(), and forget() take no parameters. sendReport(reportId, data) and sendFeatureReport(reportId, data) take an 8-bit reportId (0–255, enforced via [EnforceRange]; pass 0 when the device does not use numbered report IDs) and a BufferSource (ArrayBuffer or ArrayBufferView such as Uint8Array) containing the report payload bytes excluding the leading report ID byte. receiveFeatureReport(reportId) takes an 8-bit reportId (0–255).
Outputs. Read-only properties expose opened (boolean), 16-bit vendorId and productId, human-readable productName (string), and collections (a FrozenArray<HIDCollectionInfo> parsed from the device’s HID report descriptor). open(), close(), forget(), sendReport(), and sendFeatureReport() resolve to undefined; receiveFeatureReport(reportId) resolves to a DataView containing the feature report payload. Incoming input reports fire inputreport events on the HIDDevice once opened.
hid_device.cc.
Events and report descriptor structures
Inputs & outputs. The HID interface fires connect and disconnect events (HIDConnectionEvent, carrying event.device) when a previously permitted device attaches or detaches. Each open HIDDevice fires inputreport events (HIDInputReportEvent, carrying event.device, event.reportId, and event.data as a DataView). Each HIDCollectionInfo in device.collections exposes usagePage, usage, type, nested children, and arrays of HIDReportInfo (inputReports, outputReports, featureReports). Each HIDReportInfo pairs a reportId with items (HIDReportItem[]) describing bit width (reportSize, reportCount), usages (usages, usageMinimum, usageMaximum), flags (isAbsolute, isArray, isConstant, isLinear, isRange, isVolatile, isBufferedBytes, hasNull, hasPreferredState, wrap), logical/physical ranges, and physical units (unitSystem of type HIDUnitSystem plus exponent fields).
Chrome 158 Android 17+ platform contract and enterprise policies
OS requirement & transports. On Chrome for Android 158, WebHID relies on Android 17 (API level 37) platform HID APIs (android.hardware.hid.HidDevice, supporting USB and Bluetooth HID transports as well as platform-enumerated HID transports mapped in Chromium’s HidServiceAndroid). On Android versions earlier than Android 17 (API level < 37), the underlying OS HID manager is unavailable; applications should always feature-detect "hid" in navigator and handle empty chooser results gracefully. Android WebView is not supported because WebView does not provide a device chooser UI or site-permission controls.
Permissions Policy & enterprise policies. Sites and administrators control WebHID access via the hid Permissions Policy (default allowlist 'self'; cross-origin iframes require allow="hid" plus header opt-in) and six Chrome Enterprise policies:
| Enterprise policy | Effect |
|---|---|
DefaultWebHidGuardSetting | Sets the default permission policy (ask vs. block) for sites requesting HID access. |
WebHidAllowAllDevicesForUrls | Automatically grants listed origins access to all connected HID devices without prompting. |
WebHidAllowDevicesForUrls | Automatically grants listed origins access to devices matching specific USB vendor/product IDs. |
WebHidAllowDevicesWithHidUsagesForUrls | Automatically grants listed origins access to devices exposing specific HID usage pages/usages. |
WebHidAskForUrls | Allows listed origins to prompt users for HID access even when the default guard blocks prompts. |
WebHidBlockedForUrls | Blocks listed origins from requesting or accessing any HID devices. |
hid_service_android.cc; Chrome Enterprise Help — Device policies.
Errors and recovery
All asynchronous WebHID methods return promises that reject rather than throwing synchronously once IDL argument conversion succeeds:
| Error | When raised | Recovery |
|---|---|---|
SecurityError | requestDevice() called without transient user activation; API disallowed by hid Permissions Policy; or called from a context with an opaque top-level origin. (When blocked by enterprise policies such as DefaultWebHidGuardSetting or on unsupported Android WebView / pre-Android 17 environments, prompts are suppressed or navigator.hid is absent.) | Call requestDevice() inside a click/tap handler; ensure top-level HTTPS origin, hid Permissions Policy allowlist, and feature-detect "hid" in navigator. |
TypeError | Invalid filter in filters or exclusionFilters (for example, productId without vendorId, usage without usagePage, or empty exclusionFilters: []); or reportId outside 0..255. | Validate filter pairs before calling requestDevice(); omit exclusionFilters when empty; clamp reportId to 0..255. |
InvalidStateError | Calling open() on an already-open device; calling sendReport(), sendFeatureReport(), or receiveFeatureReport() while device.opened is false; or issuing a call while an open/close/forget state change is already in progress. | Check device.opened and serialize state transitions (await device.open() before report I/O). |
NotAllowedError | Device open or report transfer rejected by the OS/device, or the targeted report in a HIDCollectionInfo entry belongs to a protected HID usage (such as standard keyboard/mouse or FIDO CTAP, which also prevents HIDInputReportEvent delivery for protected reports). | Inspect device.collections for non-protected usages; inform the user if another native app holds exclusive access to the HID interface. |
NotSupportedError | Execution context has detached, or a report buffer exceeds the maximum transfer size supported by the browser/OS. | Re-acquire device handles in an active document/worker and keep report buffers within descriptor report byte lengths. |
hid.cc; Blink hid_device.cc; WHATWG WebHID Living Standard.
Context and exposure
WebHID requires a Secure Context (https:// or localhost) and is governed by the hid Permissions Policy (default 'self'). navigator.hid, HID, HIDDevice, HIDConnectionEvent, and HIDInputReportEvent are exposed on Window and DedicatedWorker (WorkerNavigator.hid); HID.requestDevice() is exposed on Window only and requires transient user activation. In Chromium, exposure on ServiceWorker is gated separately behind the extension-only WebHIDOnServiceWorkers runtime flag. On Android, WebHID is exposed in Chrome 158+ (backed by Android 17 / API level 37+) and is not exposed in Android WebView.
hid.idl; Blink worker_navigator_hid.idl; Blink runtime_enabled_features.json5; ChromeStatus 5172464636133376.
Lifecycle and state transitions
A WebHID session progresses through four states: (1) Permission grant via navigator.hid.requestDevice() (user gesture required) or recall of previously granted devices via navigator.hid.getDevices(); (2) Connection open via await device.open(), transitioning device.opened from false to true and enabling inputreport event dispatch and report I/O; (3) Active I/O & hotplug, listening to device.oninputreport, sending reports via sendReport()/sendFeatureReport(), reading feature reports via receiveFeatureReport(), and handling navigator.hid connect/disconnect events; and (4) Teardown / revocation via await device.close() (releases the OS handle while keeping permission) or await device.forget() (closes the handle if open and permanently revokes the origin’s permission until the user re-grants it). Concurrent open()/close()/forget() calls reject with InvalidStateError.
hid_device.cc.
Examples
No interactive Chrome Platform Showcase demo exists yet for v158/support-for-webhid (checked 2026-11-24). See Google’s WebHID device examples guide for real-hardware recipes (Nintendo Joy-Con, Elgato Stream Deck, Blink(1), headsets).
Requesting a HID device, opening it, and exchanging reports (desktop & Android 17+)
const connectBtn = document.querySelector("#connect-hid");
function isWebHidAvailable() {
return "hid" in navigator;
}
async function openAndListen(device) {
if (!device.opened) {
await device.open();
}
device.addEventListener("inputreport", (event) => {
const bytes = new Uint8Array(
event.data.buffer,
event.data.byteOffset,
event.data.byteLength,
);
console.log(`Report 0x${event.reportId.toString(16)}:`, bytes);
});
// Example: send an output report (reportId 0x01) and read a feature report
const payload = new Uint8Array([0x01, 0x00, 0xff]);
await device.sendReport(0x01, payload);
const feature = await device.receiveFeatureReport(0x02);
console.log("Feature report bytes:", new Uint8Array(feature.buffer));
}
if (isWebHidAvailable()) {
// Reconnect already-permitted devices on page load (no gesture needed)
const existing = await navigator.hid.getDevices();
for (const device of existing) {
await openAndListen(device);
}
navigator.hid.addEventListener("disconnect", ({ device }) => {
console.log("Disconnected:", device.productName);
});
connectBtn.addEventListener("click", async () => {
try {
const devices = await navigator.hid.requestDevice({
filters: [{ usagePage: 0x0b }], // Telephony (e.g. USB/Bluetooth headset)
});
if (devices.length === 0) return; // User dismissed chooser
await openAndListen(devices[0]);
} catch (err) {
console.error(`WebHID error (${err.name}):`, err.message);
}
});
}
Source: WHATWG WebHID §Examples; web.dev — Connecting to uncommon HID devices.
Inspecting HIDCollectionInfo descriptors and revoking device permission
// Each element of device.collections is a HIDCollectionInfo dictionary
function summarizeCollections(device) {
return device.collections.map((col) => ({
usagePage: `0x${col.usagePage.toString(16)}`,
usage: `0x${col.usage.toString(16)}`,
inputReportIds: col.inputReports.map((r) => r.reportId),
outputReportIds: col.outputReports.map((r) => r.reportId),
featureReportIds: col.featureReports.map((r) => r.reportId),
}));
}
async function disconnectAndForget(device) {
if (device.opened) {
await device.close();
}
// Revokes origin permission permanently until re-requested
await device.forget();
}
Source: WHATWG WebHID §Report Descriptor; WHATWG WebHID HIDDevice.forget().
Browser compatibility
| Browser / platform | Support | Notes & evidence |
|---|---|---|
| Chrome (desktop) | 89 | Windows, macOS, Linux, and ChromeOS per BCD api/HID.json and ChromeStatus. |
| Chrome (Android) | 158 | Enabled by default on Android 17 (API level 37) and later per ChromeStatus 5172464636133376 and blink-dev Intent to Ship. BCD has not yet updated from false. |
| Android WebView | No | Explicitly unsupported: lacks device chooser UI and permission controls (ChromeStatus; crbug.com/40163407). |
| Edge | 89 (desktop) | Mirrors Chromium on desktop per BCD and webstatus.dev; Edge on Android support is unconfirmed. |
| Firefox | No | Not supported; Mozilla standards position: Negative. |
| Safari / WebKit | No | Not supported; WebKit standards position: Oppose. |
api/HID.json; webstatus.dev webhid; ChromeStatus API record 5172464636133376.
Security and privacy
Direct hardware access carries significant fingerprinting, keylogging, and firmware-tampering risks. WebHID mitigates these through five layers that apply identically on desktop and Android 17+:
- Explicit per-device user consent: Origins cannot enumerate arbitrary HID devices;
getDevices()returns only devices the user has explicitly selected in the browser-controlled chooser UI triggered byrequestDevice()with transient user activation. - Protected-usage blocklist: Browsers block top-level collections and reports belonging to security-sensitive usages (such as standard keyboards, pointing devices, and FIDO/U2F security keys) so a web page cannot intercept keystrokes or credentials.
- Secure context & origin isolation: Exposed only in secure contexts (
https:///localhost), denied in opaque top-level origins, and gated by thehidPermissions Policy ('self'by default). - Revocable permissions & enterprise governance: Users can revoke grants in site settings or via
device.forget(), and enterprise administrators can block or scope access through the six Chrome WebHID enterprise policies. - WebView exclusion: Android WebView does not ship WebHID because embedded WebViews lack a trusted browser-chrome device chooser and permission management UI.
Specifications
| Specification | Section |
|---|---|
| WebHID API (WHATWG Living Standard) | Enumeration, Device Usage, Report Descriptor, and Permissions Policy |