SerialPort: connect event

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.

Note: This feature is available in Dedicated Web Workers.

The connect event of the SerialPort interface is fired when the port connects to the device.

Description

More specifically, the connect event fires when the port becomes logically connected to the device after a user grants permission for a site to access the port following a Serial.requestPort() call:

  • In the case of a wired serial port, this occurs when the port is physically connected to the device, for example via USB.
  • In the case of a wireless serial port (for example, Bluetooth RFCOMM), this occurs when the port makes one or more active connections to the device (for example via Bluetooth L2CAP channels).

Bubbling

This event bubbles to the instance of Serial that returned this interface. The event.target property refers to the SerialPort object that bubbles up.

For more information, see Event bubbling.

Syntax

Use the event name in methods like addEventListener(), or set an event handler property.

js
addEventListener("connect", (event) => { })

onconnect = (event) => { }

Event type

A generic Event.

Examples

Notify when a specific port connects

The Serial.requestPort() method returns a Promise that resolves with a SerialPort chosen by the user.

js
// Prompt user to choose a serial port
const port = await navigator.serial.requestPort();

port.addEventListener("connect", (event) => {
  // notify that the chosen port is connected
});

Listening for any newly-connected ports

The connect event bubbles up to the Serial object where you can listen for any newly-connected ports.

js
navigator.serial.addEventListener("connect", (event) => {
  // notify that a new port is available
  // use `event.target` to refer to the newly-added port
});

Specifications

Specification
Web Serial API
# dfn-connect
Web Serial API
# dom-serialport-onconnect

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
connect event
Chrome – Full support
Chrome 89 (Release date: 2021-03-02)
footnote Full support
Edge – Full support
Edge 89 (Release date: 2021-03-04)
footnote Full support
Firefox – Preview support
Firefox 151 (Release date: 2026-05-19)
footnote Preview browser support
Opera – Full support
Opera 75 (Release date: 2021-03-24)
footnote Full support
Safari – No support
Safari
footnote No support
Chrome Android – Full support
Chrome Android 138 (Release date: 2025-06-24)
footnote Full support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – Full support
Opera Android 91 (Release date: 2025-08-19)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – No support
WebView Android
footnote
footnote See bug 40740509
WebView on iOS – No support
WebView on iOS
footnote No support
Bluetooth RFCOMM serial ports dispatch connect events
Experimental
Chrome – Full support
Chrome 130 (Release date: 2024-10-15)
footnote Full support
Edge – Full support
Edge 130 (Release date: 2024-10-17)
footnote Full support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 115 (Release date: 2024-11-27)
footnote Full support
Safari – No support
Safari
footnote No support
Chrome Android – Full support
Chrome Android 138 (Release date: 2025-06-24)
footnote Full support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – Full support
Opera Android 91 (Release date: 2025-08-19)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – No support
WebView Android
footnote
footnote See bug 40740509
WebView on iOS – No support
WebView on iOS
footnote No support

Legend

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

Full support
Full support
In development. Supported in a pre-release version.
In development. Supported in a pre-release version.
No support
No support
Experimental. Expect behavior to change in the future.
See implementation notes.

See also