Skip to content
AnswerWell geo Documentation

Research · 7 min read · Answerwell

Hardware Web APIs: USB, HID, Bluetooth, and Serial Device Access

When to use WebUSB, WebHID, Web Bluetooth, and Web Serial in the browser, plus permissions, platform limits, and how they differ from legacy Chrome Apps.

This page summarises Chrome’s hardware capabilities documentation (Project Fugu): how websites access physical devices with JavaScript, which API fits which hardware, and what security and operating-system rules apply. Modern pages rely on navigator.usb, navigator.hid, navigator.bluetooth, and navigator.serial. Older chrome.usb, chrome.bluetooth, and chrome.serial APIs belong to Chrome Apps, which Chrome is removing—migrate to the web platform APIs instead.

Learn about the hardware APIs we work on in the context of Project Fugu that allow you to access physical devices from the web.

— Google, Capabilities

Each API targets a different layer of the stack. Many standard classes already have dedicated web APIs; vendor-specific or uncommon devices need a lower-level API.

Pick the appropriate API to communicate with a hardware device of your choice.

— Google, Capabilities

Situation Preferred API Chrome documentation
Standard HID keyboards, mice, gamepads (OS driver handles them) Gamepad API, keyboard/pointer events, or WebHID only for uncommon HID devices Connect to uncommon HID devices
Vendor-specific USB interface, firmware tools, non-class devices WebUSB API Access USB Devices on the Web
Nearby Bluetooth Low Energy peripherals (GATT) Web Bluetooth API Communicating with Bluetooth devices over JavaScript
Serial port, USB-CDC, or Bluetooth RFCOMM exposed as serial Web Serial API Read from and write to a serial port

Many of the standard USB classes have corresponding web APIs. For example, a page can capture video from a video class device using getUserMedia() or receive input events from a human interface (HID) class device by listening for KeyboardEvents or PointerEvents, or by using the Gamepad or the WebHID API. Just as not all devices implement a standardized class definition, not all devices implement features that correspond to existing web platform APIs. When this is the case the WebUSB API can fill that gap by providing a way for sites to claim a vendor-specific interface and implement support for it from directly within their page.

— Google, Building a device for WebUSB

For boards that speak USB serial (CDC-ACM), the OS often exposes a serial port rather than raw USB. The Web Serial guide notes that Web Serial is a companion to WebUSB when the platform expects the serial abstraction. On Android, CDC-ACM may be missing from the OS, so fewer devices appear as serial ports than on desktop Linux.

Shared security model: user gesture, picker, and forget()

Section titled “Shared security model: user gesture, picker, and forget()”

All four modern APIs gate powerful access behind explicit user choice.

requestDevice() and requestPort() need a user gesture

Section titled “requestDevice() and requestPort() need a user gesture”

Device discovery and permission prompts must run from a user gesture (click, touch, pointerup):

As a security precaution, navigator.usb.requestDevice() may only be called through a user gesture such as a touch or mouse click.

— Google, Access USB Devices on the Web

The same pattern applies to Web Bluetooth (navigator.bluetooth.requestDevice), WebHID (navigator.hid.requestDevice), and Web Serial (navigator.serial.requestPort).

One device at a time through the permission model

Section titled “One device at a time through the permission model”

WebHID and Web Serial document a permission model that grants access to one device at a time after the user selects it in a browser prompt. WebUSB uses filters (vendorId, productId, and optional class codes) so the chooser only lists matching devices—see Access USB Devices on the Web.

Previously granted devices can be reopened without a new picker via getDevices() (WebUSB/WebHID) or getPorts() (Web Serial).

Educational or kiosk setups accumulate permissions. Each API supports voluntary cleanup:

await device.forget();

WebUSB documents forget() from Chrome 101; WebHID from Chrome 100; Web Serial from Chrome 103. Feature-detect with "forget" in USBDevice.prototype (or the matching prototype for HID/Serial).

WebUSB API: connect, claim interface, transfer

Section titled “WebUSB API: connect, claim interface, transfer”

The WebUSB API makes USB safer and easier to use by bringing it to the Web.

— Google, Access USB Devices on the Web

Typical flow: navigator.usb.requestDevice({ filters: [...] }) → device.open() → selectConfiguration() → claimInterface() → transferIn() / transferOut() / control transfers. The API exposes control, bulk, interrupt, and isochronous transfer types on endpoints.

Devices that publish WebUSB BOS descriptors can advertise a landing page URL; Chrome may show a plug-in notification that opens that URL—see Building a device for WebUSB.

the basic requirement is that a device should not already have a driver claiming the interface the page wants to control.

— Google, Building a device for WebUSB

Composite devices can leave one interface (for example HID typing) to the OS and expose a vendor-specific interface to the page—illustrated in the configuration-descriptor example in Building a device for WebUSB.

Linux: default USB node permissions are often read-only; add a udev rule assigning GROUP="plugdev" and reconnect—described in both Access USB Devices on the Web and Building a device for WebUSB.

Windows: applications need the WinUSB driver via an INF install or Microsoft OS 2.0 compatibility descriptors in firmware (Windows 8.1+); see Building a device for WebUSB.

Android: extra confirmation when allowing Chrome to access a device; open() can re-prompt. Plug-in notifications for landing pages are not available on Android yet.

Debug with about://device-log and about://usb-internals (Access USB Devices on the Web).

WebHID API: reports for uncommon human-interface devices

Section titled “WebHID API: reports for uncommon human-interface devices”

The WebHID API allows websites to access alternative auxiliary keyboards and exotic gamepads.

— Google, Connect to uncommon HID devices

WebHID is for devices too uncommon for built-in OS HID drivers—stream decks, exotic gamepads, auxiliary keypads. Flow: navigator.hid.requestDevice({ filters }) → device.open() → listen for inputreport events or call sendReport() / sendFeatureReport().

Chrome blocks protected usages (generic keyboard, mouse) and security-sensitive devices (including FIDO) from arbitrary report access; see the protected-usage list referenced in Connect to uncommon HID devices. Linux uses hidraw udev rules analogous to WebUSB.

The Web Bluetooth API allows websites to communicate with Bluetooth devices.

— Google, Communicating with Bluetooth devices over JavaScript

Sites act as a GATT central: requestDevice({ filters: [{ services: [...] }] }) → device.gatt.connect() → getPrimaryService() → read/write characteristics or startNotifications(). Filters can target GATT service UUIDs, name, namePrefix, manufacturerData, or acceptAllDevices (discouraged without tight filters).

After disconnect, GATT handles are invalid—re-fetch services and characteristics on reconnect. Queue GATT operations; parallel reads/writes can error on some platforms (Communicating with Bluetooth devices over JavaScript). Inspect devices at about://bluetooth-internals.

Web Serial API: byte streams and microcontroller tooling

Section titled “Web Serial API: byte streams and microcontroller tooling”

The Web Serial API allows websites to communicate with serial devices.

— Google, Read from and write to a serial port

Open with navigator.serial.requestPort() (optional usbVendorId / usbProductId filters), then port.open({ baudRate: 9600, ... }). Reading and writing use the Streams API (port.readable, port.writable). connect and disconnect events track hot-plugged USB serial adapters.

Available on desktop Chrome 89+; Android may use WebUSB plus a serial polyfill when the device is not claimed by a built-in driver (Read from and write to a serial port).

Extensions use the same web APIs without extra manifest permissions; the browser permission flow still applies (Use WebUSB, Use WebHID).

requestDevice() cannot run inside an extension service worker. Pattern: call requestDevice() from a popup or options page on user click, then message the worker, which calls getDevices() and open().

An open device session keeps the service worker alive while connected.

Documents such as USB Devices and Bluetooth describe chrome.usb, chrome.bluetooth, chrome.bluetoothSocket, and manifest usbDevices / bluetooth entries. Chrome is removing Chrome Apps; new work should use the navigator.* APIs above. Chrome Apps required manifest-declared VID/PID lists; web APIs use runtime user selection instead (kiosk interfaceClass rules were special-cased on ChromeOS only).

  • Calling requestDevice() outside a user gesture (fails silently or rejects).
  • Using WebUSB on interfaces already claimed by kernel class drivers (storage, standard HID, cameras).
  • For Web Bluetooth name-only filters, omitting optionalServices for services you will use later.
  • Assuming GATT objects remain valid after gattserverdisconnected without re-discovery.
  • Leaving serial readable locked (reader not releaseLock()) so port.close() never succeeds.
  • On Linux, forgetting plugdev membership or udev rules—Chrome cannot fix permissions for the user.
  • On Windows, shipping firmware without WinUSB or Microsoft OS 2.0 descriptors, forcing manual INF install.
  1. Confirm support with feature detection ("usb" in navigator, "hid" in navigator, "serial" in navigator, "bluetooth" in navigator) as shown in Connect to uncommon HID devices and Read from and write to a serial port.

  2. Trigger your connect button from a real click, complete the browser device picker, and verify open() succeeds without NotFoundError or permission errors.

  3. For USB/HID/serial issues on Linux, check lsusb, device node permissions, and your udev rules against Building a device for WebUSB or the Linux tips in Access USB Devices on the Web.

  4. In Chrome, open about://device-log (and for Bluetooth, about://bluetooth-internals) while reproducing connect, transfer, and disconnect.

  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact sentence you are asking about, and we will correct or clarify it.