HIDDevice: open() method

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

Note: This feature is available in Web Workers, except for Shared Web Workers.

The open() method of the HIDDevice interface requests that the operating system opens the HID device.

Note: HID devices are not opened automatically. Therefore, a HIDDevice returned by HID.requestDevice() must be opened with this method before it is available to transfer data.

Syntax

js
open()

Parameters

None.

Return value

A Promise that resolves with undefined once the connection is opened.

Exceptions

InvalidStateError DOMException

Thrown if the connection is already open.

NotAllowedError DOMException

Thrown if the attempt to open the connection fails for any reason.

Examples

In the following example, we wait for the HID connection to open before attempting to send or receive data.

js
await device.open();

Specifications

Specification
WebHID API
# dom-hiddevice-open

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
open
Experimental

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Experimental. Expect behavior to change in the future.