v154 · webhid on android
Where you are, and whether that matters
"Does this browser have WebHID?" and "am I on Android?" are different questions, and this feature is entirely about the second one. Both are answered here from user-agent client hints rather than from a parsed string, and the difference between those two sources is worth a demo of its own.
This browser, this device
Reading…
| question | answer | source | how good is it? |
|---|
The high-entropy hints are behind a promise on purpose: a page has to ask, and the browser may decline. That is the difference between a hint and the user-agent string, which hands everything to everyone whether or not they wanted it.
What the platform changes
| platform | navigator.hid | specialised devices | what it means for a page |
|---|
Only the row for this browser is measured; the others are what the feature entry describes, and are labelled as such. A page cannot test another platform from here, and a table that pretended otherwise would be the most misleading thing on this site.
How to write the check
// Wrong: the platform is not the capability.
if (isAndroid()) { /* … */ }
// Also wrong: the capability is not the permission.
if (navigator.hid) { /* … */ }
// The three questions, in the order they can actually be answered:
if (!navigator.hid) return unsupported(); // no API at all
const known = await navigator.hid.getDevices(); // already allowed?
if (known.length === 0) offerAChooserButton(); // needs a gesture
The platform never appears. It decides whether the first line succeeds, and once it has, it tells you nothing further — which is why this page measures it and then puts it away.