MDN self-hosted library · e01.org

SerialPort: disconnect event

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

js
port.addEventListener("disconnect", (event) => {
  // notify that the port has become unavailable
});
js
navigator.serial.addEventListener("disconnect", (event) => {
  // notify that a port has become unavailable
  // use `event.target` to refer to the unavailable port
});