WebUSB
The WebUSB API exposes USB compatible devices to web pages. It is most useful when native HTML semantics or browser capabilities can replace custom implementation work.
Overview
The WebUSB API exposes USB compatible devices to web pages. It is most useful when native HTML semantics or browser capabilities can replace custom implementation work.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
USB Experimental | 61 | 79 | | | 61 | |
| The usb read-only property of the Navigator interface returns a USB object for the current document, providing access to WebUSB API functionality. | 61 | 79 | | | 61 | |
connect_event Experimental The connect event of the USB interface is fired whenever a paired device is connected. | 61 | 79 | | | 61 | |
disconnect_event Experimental The disconnect event of the USB interface is fired whenever a paired device is disconnected. | 61 | 79 | | | 61 | |
getDevices Experimental The getDevices method of the USB interface returns a Promise that resolves with an array of USBDevice objects for paired attached devices. For information on pairing devices, see USB.requestDevice(). | 61 | 79 | | | 61 | |
requestDevice Experimental The requestDevice() method of the USB interface returns a Promise that resolves with an instance of USBDevice if the specified device is found. Calling this function triggers the user agent's pairing flow. | 61 | 79 | | | 61 | |
worker_support Experimental Available in workers | 118 | 118 | | | 118 | |
USBAlternateInterface Experimental The USBAlternateInterface interface of the WebUSB API provides information about a particular configuration of an interface provided by the USB device. An interface includes one or more alternate settings which can configure a set of endpoints based on the operating mode of the device. | 61 | 79 | | | 61 | |
alternateSetting Experimental | 61 | 79 | | | 61 | |
endpoints Experimental | 61 | 79 | | | 61 | |
interfaceClass Experimental | 61 | 79 | | | 61 | |
interfaceName Experimental | 61 | 79 | | | 61 | |
interfaceProtocol Experimental | 61 | 79 | | | 61 | |
interfaceSubclass Experimental | 61 | 79 | | | 61 | |
USBAlternateInterface Experimental `USBAlternateInterface()` constructor | 61 | 79 | | | 61 | |
worker_support Experimental Available in workers | 118 | 118 | | | 118 | |
USBConfiguration Experimental The USBConfiguration interface of the WebUSB API provides information about a particular configuration of a USB device and the interfaces that it supports. | 61 | 79 | | | 61 | |
configurationName Experimental The configurationName read-only property of the USBConfiguration interface returns the name provided by the device to describe this configuration. This is equal to the value of the string descriptor with the index provided in the iConfiguration field of the configuration descriptor defining this configuration. | 61 | 79 | | | 61 | |
configurationValue Experimental The configurationValue read-only property of the USBConfiguration interface returns the configuration value of this configuration. This is equal to the bConfigurationValue field of the configuration descriptor provided by the device defining this configuration. | 61 | 79 | | | 61 | |
interfaces Experimental The interfaces read-only property of the USBConfiguration interface returns an array containing instances of the USBInterface describing each interface supported by this configuration. | 61 | 79 | | | 61 | |
USBConfiguration Experimental The USBConfiguration() constructor creates a new USBConfiguration object which contains information about the configuration on the provided USBDevice with the given configuration value. | 61 | 79 | | | 61 | |
worker_support Experimental Available in workers | 118 | 118 | | | 118 | |
USBConnectionEvent Experimental The USBConnectionEvent interface of the WebUSB API is the event type passed to USB USB.connectevent and USB.disconnectevent events when the user agent detects that a new USB device has been connected or disconnected. | 61 | 79 | | | 61 | |
device Experimental The device read-only property of the USBConnectionEvent interface returns a USBDevice object representing the device being connected or disconnected. | 61 | 79 | | | 61 | |
USBConnectionEvent Experimental The USBConnectionEvent() constructor creates a new USBConnectionEvent object. This constructor is not typically used, it is created by the browser in response to the connection and disconnection of a USB device. | 61 | 79 | | | 61 | |
worker_support Experimental Available in workers | 118 | 118 | | | 118 | |
USBDevice Experimental The USBDevice interface of the WebUSB API provides access to metadata about a paired USB device and methods for controlling it. | 61 | 79 | | | 61 | |
claimInterface Experimental The claimInterface() method of the USBDevice interface returns a promise that resolves when the requested interface is claimed for exclusive access. | 61 | 79 | | | 61 | |
clearHalt Experimental The clearHalt() method of the USBDevice interface returns a promise that resolves when a halt condition is cleared. A halt condition is when a data transfer to or from the device has a status of 'stall', which requires the web page (the host system, in USB terminology) to clear that condition. See the for details. | 61 | 79 | | | 61 | |
close Experimental The close() method of the USBDevice interface returns a promise that resolves when all open interfaces are released and the device session has ended. | 61 | 79 | | | 61 | |
configuration Experimental The configuration read only property of the USBDevice interface returns a USBConfiguration object for the currently selected interface for a paired USB device. | 61 | 79 | | | 61 | |
configurations Experimental The configurations read only property of the USBDevice interface an array of device-specific interfaces for controlling a paired USB device. | 61 | 79 | | | 61 | |
controlTransferIn Experimental The controlTransferIn() method of the USBDevice interface returns a Promise that resolves with a USBInTransferResult when a command or status request has been transmitted to (received by) the USB device. | 61 | 79 | | | 61 | |
controlTransferOut Experimental The controlTransferOut() method of the USBDevice interface returns a Promise that resolves with a USBOutTransferResult when a command or status operation has been transmitted from the USB device. | 61 | 79 | | | 61 | |
deviceClass Experimental The deviceClass read only property of the USBDevice interface one of three properties that identify USB devices for the purpose of loading a USB driver that will work with that device. The other two properties are USBDevice.deviceSubclass and USBDevice.deviceProtocol. | 61 | 79 | | | 61 | |
deviceProtocol Experimental The deviceProtocol read only property of the USBDevice interface one of three properties that identify USB devices for the purpose of loading a USB driver that will work with that device. The other two properties are USBDevice.deviceClass and USBDevice.deviceSubclass. | 61 | 79 | | | 61 | |
deviceSubclass Experimental The deviceSubclass read only property of the USBDevice interface one of three properties that identify USB devices for the purpose of loading a USB driver that will work with that device. The other two properties are USBDevice.deviceClass and USBDevice.deviceProtocol. | 61 | 79 | | | 61 | |
deviceVersionMajor Experimental The deviceVersionMajor read only property of the USBDevice interface he major version number of the device in a semantic versioning scheme. | 61 | 79 | | | 61 | |
deviceVersionMinor Experimental The deviceVersionMinor read only property of the USBDevice interface the minor version number of the device in a semantic versioning scheme. | 61 | 79 | | | 61 | |
deviceVersionSubminor Experimental The deviceVersionSubminor read only property of the USBDevice interface the patch version number of the device in a semantic versioning scheme. | 61 | 79 | | | 61 | |
forget Experimental The forget() method of the USBDevice interface returns a Promise that resolves when all pending operations are aborted, all open interfaces are released, the device session has ended, and the permission is reset. | 101 | 101 | | | 101 | |
isochronousTransferIn Experimental The isochronousTransferIn() method of the USBDevice interface returns a Promise that resolves with a USBIsochronousInTransferResult when time sensitive information has been transmitted to (received by) the USB device. | 61 | 79 | | | 61 | |
isochronousTransferOut Experimental The isochronousTransferOut() method of the USBDevice interface returns a Promise that resolves with a USBIsochronousOutTransferResult when time sensitive information has been transmitted from the USB device. | 61 | 79 | | | 61 | |
manufacturerName Experimental The manufacturerName read only property of the USBDevice interface the of the organization that manufactured the USB device. | 61 | 79 | | | 61 | |
open Experimental The open() method of the USBDevice interface returns a promise that resolves when a device session has started. | 61 | 79 | | | 61 | |
opened Experimental The opened read only property of the USBDevice interface indicates whether a session has been started with a paired USB device. A device must be opened before it can be controlled by a web page. | 61 | 79 | | | 61 | |
productId Experimental The productId read only property of the USBDevice interface the manufacturer-defined code that identifies a USB device. | 61 | 79 | | | 61 | |
productName Experimental The productName read only property of the USBDevice interface the manufacturer-defined name that identifies a USB device. | 61 | 79 | | | 61 | |
releaseInterface Experimental The releaseInterface() method of the USBDevice interface returns a promise that resolves when a claimed interface is released from exclusive access. | 61 | 79 | | | 61 | |
reset Experimental The reset() method of the USBDevice interface returns a promise that resolves when the device is reset and all app operations canceled and their promises rejected. | 61 | 79 | | | 61 | |
selectAlternateInterface Experimental The selectAlternateInterface() method of the USBDevice interface returns a promise that resolves when the specified alternative endpoint is selected. | 61 | 79 | | | 61 | |
selectConfiguration Experimental The selectConfiguration() method of the USBDevice interface returns a promise that resolves when the specified configuration is selected. | 61 | 79 | | | 61 | |
serialNumber Experimental The serialNumber read only property of the USBDevice interface is the manufacturer-defined serial number for the specific USB device. | 61 | 79 | | | 61 | |
transferIn Experimental The transferIn() method of the USBDevice interface returns a promise that resolves with a USBInTransferResult when bulk or interrupt data is received from the USB device. | 61 | 79 | | | 61 | |
transferOut Experimental The transferOut() method of the USBDevice interface returns a promise that resolves with a USBOutTransferResult when bulk or interrupt data is sent to the USB device. | 61 | 79 | | | 61 | |
usbVersionMajor Experimental The usbVersionMajor read only property of the USBDevice interface is one of three properties that declare the USB protocol version supported by the device. The other two properties are USBDevice.usbVersionMinor and USBDevice.usbVersionSubminor. | 61 | 79 | | | 61 | |
usbVersionMinor Experimental The usbVersionMinor read only property of the USBDevice interface is one of three properties that declare the USB protocol version supported by the device. The other two properties are USBDevice.usbVersionMajor and USBDevice.usbVersionSubminor. | 61 | 79 | | | 61 | |
usbVersionSubminor Experimental The usbVersionSubminor read only property of the USBDevice interface is one of three properties that declare the USB protocol version supported by the device. The other two properties are USBDevice.usbVersionMajor and USBDevice.usbVersionMinor. | 61 | 79 | | | 61 | |
vendorId Experimental The vendorId read only property of the USBDevice interface is the official usb.org-assigned vendor ID. | 61 | 79 | | | 61 | |
worker_support Experimental Available in workers | 118 | 118 | | | 118 | |
USBEndpoint Experimental The USBEndpoint interface of the WebUSB API provides information about an endpoint provided by the USB device. An endpoint represents a unidirectional data stream into or out of a device. | 61 | 79 | | | 61 | |
direction Experimental | 61 | 79 | | | 61 | |
endpointNumber Experimental | 61 | 79 | | | 61 | |
packetSize Experimental | 61 | 79 | | | 61 | |
type Experimental | 61 | 79 | | | 61 | |
USBEndpoint Experimental `USBEndpoint()` constructor | 61 | 79 | | | 61 | |
worker_support Experimental Available in workers | 118 | 118 | | | 118 | |
USBInterface Experimental The USBInterface interface of the WebUSB API provides information about an interface provided by the USB device. An interface represents a feature of the device which implements a particular protocol and may contain endpoints for bidirectional communication. | 61 | 79 | | | 61 | |
alternate Experimental | 61 | 79 | | | 61 | |
alternates Experimental | 61 | 79 | | | 61 | |
claimed Experimental | 61 | 79 | | | 61 | |
interfaceNumber Experimental | 61 | 79 | | | 61 | |
USBInterface Experimental `USBInterface()` constructor | 61 | 79 | | | 61 | |
worker_support Experimental Available in workers | 118 | 118 | | | 118 | |
USBInTransferResult Experimental The USBInTransferResult interface of the WebUSB API provides the result from a call to the transferIn() and controlTransferIn() methods of the USBDevice interface. It represents the result from requesting a transfer of data from the USB device to the USB host. | 61 | 79 | | | 61 | |
data Experimental | 61 | 79 | | | 61 | |
status Experimental | 61 | 79 | | | 61 | |
USBInTransferResult Experimental `USBInTransferResult()` constructor | 61 | 79 | | | 61 | |
worker_support Experimental Available in workers | 118 | 118 | | | 118 | |
USBIsochronousInTransferPacket Experimental The USBIsochronousInTransferPacket interface of the WebUSB API is part of the response from a call to the isochronousTransferIn() method of the USBDevice interface. It represents the status of an individual packet from a request to transfer data from the USB device to the USB host over an isochronous endpoint. | 61 | 79 | | | 61 | |
data Experimental | 61 | 79 | | | 61 | |
status Experimental | 61 | 79 | | | 61 | |
USBIsochronousInTransferPacket Experimental `USBIsochronousInTransferPacket()` constructor | 61 | 79 | | | 61 | |
worker_support Experimental Available in workers | 118 | 118 | | | 118 | |
USBIsochronousInTransferResult Experimental The USBIsochronousInTransferResult interface of the WebUSB API provides the result from a call to the isochronousTransferIn() method of the USBDevice interface. It represents the result from requesting a transfer of data from the USB device to the USB host. | 61 | 79 | | | 61 | |
data Experimental | 61 | 79 | | | 61 | |
packets Experimental | 61 | 79 | | | 61 | |
USBIsochronousInTransferResult Experimental `USBIsochronousInTransferResult()` constructor | 61 | 79 | | | 61 | |
worker_support Experimental Available in workers | 118 | 118 | | | 118 | |
USBIsochronousOutTransferPacket Experimental The USBIsochronousOutTransferPacket interface of the WebUSB API is part of the response from a call to the isochronousTransferOut() method of the USBDevice interface. It represents the status of an individual packet from a request to transfer data from the USB host to the USB device over an isochronous endpoint. | 61 | 79 | | | 61 | |
bytesWritten Experimental | 61 | 79 | | | 61 | |
status Experimental | 61 | 79 | | | 61 | |
USBIsochronousOutTransferPacket Experimental `USBIsochronousOutTransferPacket()` constructor | 61 | 79 | | | 61 | |
worker_support Experimental Available in workers | 118 | 118 | | | 118 | |
USBIsochronousOutTransferResult Experimental The USBIsochronousOutTransferResult interface of the WebUSB API provides the result from a call to the isochronousTransferOut() method of the USBDevice interface. It represents the result from requesting a transfer of data from the USB host to the USB device. | 61 | 79 | | | 61 | |
packets Experimental | 61 | 79 | | | 61 | |
USBIsochronousOutTransferResult Experimental `USBIsochronousOutTransferResult()` constructor | 61 | 79 | | | 61 | |
worker_support Experimental Available in workers | 118 | 118 | | | 118 | |
USBOutTransferResult Experimental The USBOutTransferResult interface of the WebUSB API provides the result from a call to the transferOut() and controlTransferOut() methods of the USBDevice interface. It represents the result from requesting a transfer of data from the USB host to the USB device. | 61 | 79 | | | 61 | |
bytesWritten Experimental | 61 | 79 | | | 61 | |
status Experimental | 61 | 79 | | | 61 | |
USBOutTransferResult Experimental `USBOutTransferResult()` constructor | 61 | 79 | | | 61 | |
worker_support Experimental Available in workers | 118 | 118 | | | 118 | |
| The usb read-only property of the WorkerNavigator interface returns a USB object for the current document, providing access to WebUSB API functionality. | 118 | 118 | | | 118 | |
| Other | ||||||
html.elements.iframe.allow.usb Experimental | 60 | 79 | | | 60 | |
http.headers.Permissions-Policy.usb Experimental The HTTP Permissions-Policy header usb directive controls whether the current document is allowed to use the WebUSB API. | 88 | 88 | | | 88 | |
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
- This browser only partially implements this feature
- Available in dedicated workers and WebExtension service workers, not available in shared workers and normal service workers.
- Available in dedicated workers, not available in shared workers and service workers.
- This feature was removed in a later browser version (118)
Syntax
const device = await navigator.usb.requestDevice({
filters: [{ vendorId: 0x1234 }]
});
await device.open();
await device.selectConfiguration(1);
await device.claimInterface(0); Use cases
Use WebUSB
Use WebUSB when standard HTML needs a more specific platform feature, semantic signal, or browser capability.
Handle edge cases
Apply WebUSB to solve a focused requirement without redesigning the whole page architecture.
Cautions
- Test WebUSB in your target browsers and input environments before depending on it as a primary behavior.
- Provide a fallback path or acceptable degradation strategy when support is still limited.
Accessibility
- Make sure WebUSB supports the intended task without making the page harder to perceive, understand, or operate.
Related links
Powered by web-features