Serial ports for Tauri 2 apps
Desktop COM/tty ports, USB-serial adapters on Android, and serial over TCP or Bluetooth LE — including on iOS.
What you get
Open a port, watch it, write to it
List the ports, open one and stream incoming data with watch(). Binary data, AT commands and auto-reconnect use the same port object.
main.ts
import { SerialPort } from "tauri-plugin-serialplugin-api";
const ports = await SerialPort.available_ports(); // { "/dev/ttyUSB0": { type: "USB", vid, pid, … }, … }
const port = new SerialPort({ path: Object.keys(ports)[0], baudRate: 115200 });
await port.open();
const handle = await port.watch({
onData: (text) => console.log("rx", text),
onDisconnect: (reason) => console.log("gone:", reason),
});
await port.write("hello\n");
await handle.unwatch();
await port.close();