files/en-us/web/api/usb/connect_event/index.md
{{APIRef("WebUSB API")}}{{SeeCompatTable}}{{SecureContext_Header}}{{AvailableInWorkers}}
The connect event of the {{DOMxRef("USB")}} interface is fired whenever a paired device is connected.
Use the event name in methods like {{domxref("EventTarget.addEventListener", "addEventListener()")}}, or set an event handler property.
addEventListener("connect", (event) => { })
onconnect = (event) => { }
A {{domxref("USBConnectionEvent")}}. Inherits from {{domxref("Event")}}.
{{InheritanceDiagram("USBConnectionEvent")}}
In addition to the properties listed below, properties from the parent interface, {{domxref("Event")}}, are available.
Once a USB device is connected, you might want to update the UI.
navigator.usb.addEventListener("connect", (event) => {
// Add event.device to the UI.
});
Alternatively, you can use the USB.onconnect event handler property to establish a handler for the connect event:
navigator.usb.onconnect = (event) => {
// Add event.device to the UI.
};
{{Specifications}}
{{Compat}}