Utility to connect and use serial devices using the Web Serial API
- Feature detection
- Connect a device
- Read from a serial port
- Write to a serial port
- Close a serial port
- Listen to connection and disconnection
- Handle signals
- Transforming streams
- Revoke access to a serial port
import { isWebSerialSupported } from "web-serial-utils"
if (isWebSerialSupported) {
// Use other util functions (connect, read, write...)
} else {
// Fallback logic
}
import { connectToDevice } from "web-serial-utils";
const arduinoDevice = await connectToDevice({
// Arduino Uno USB example
targetDevice: {
usbProductId: 0x1234,
usbVendorId: 0x5678,
},
connectionOptions: {
baudRate: 9600,
},
});