Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Tauri Plugin — SerialPort
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 and Android.
- One API everywhere: open, stream with
watch(), read/write, line settings, modem lines, hotplug, auto-reconnect. - Modems built in: a native AT command queue with structured results, URCs, SMS (PDU) and GSM 07.10 / 27.010 CMUX.
- Android without Java libraries: USB-serial drivers in Rust (FTDI, CP210x, PL2303, CH34x, CDC-ACM, …).
- Network and radio transports:
tcp://host:portto a serial bridge,ble://<id>to Nordic UART devices.
| Local ports | tcp:// |
ble:// |
|
|---|---|---|---|
| Windows · macOS · Linux | ✅ | ✅ | ✅ (feature ble) |
| Android | ✅ USB host | ✅ | ✅ (feature ble) |
| iOS | — (no OS API) | ✅ | ✅ (feature ble) |
Install
or by hand:
Register the plugin and allow it in a capability:
// src-tauri/src/lib.rs
default
.plugin
.run
.expect;
// src-tauri/capabilities/default.json
{ "identifier": "default", "windows": ["main"], "permissions": ["core:default", "serialplugin:default"] }
Requires Rust 1.90+ and Tauri 2. Android needs no extra setup; for BLE see platforms.
Quick start
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();
Binary data: writeBinary(new Uint8Array([…])) and
watch(handlers, { decode: false }) (or readBinary()).
Talking to a modem:
const r = await port.sendAt("AT+CSQ"); // queued, waits for OK / ERROR
console.log(r.status, r.solicitedBody); // "ok", ["+CSQ: 27,0"]
Surviving unplugs:
port.enableAutoReconnect({ interval: 3000, maxAttempts: null });
// after onDisconnect the port is reopened and the watch restored
Documentation
| JavaScript API | Every method, option, event and error |
| AT commands, exchange, CMUX | Modem queue, SMS, URCs, multiplexing |
| Platforms and transports | Android USB, iOS, tcp://, ble://, DTR/RTS on open |
| Rust | Using the plugin from your backend · docs.rs |
| Permissions | Capability identifiers · full list |
| API reference | Generated from the sources: SerialPort, types, Tauri commands |
| Migration guide | v3 → v4, v2 → v3 |
| Changelog |
Upgrading from v3? Rust command functions are now async, read() decodes in
JS, watch() batches every ~20 ms; see the
migration guide.
Example app
examples/serialport-test is a terminal with port
picker, settings, AT console and hotplug, for desktop, Android and iOS:
&&
Development
&&
&& && &&
Tests run without hardware: PTY pairs, a local TCP bridge, a fake 27.010 modem,
commands through the Tauri IPC path, and a fake USB transport for the Android
drivers. For manual testing, socat -d -d pty,raw,echo=0 pty,raw,echo=0 gives a
virtual serial pair. See CONTRIBUTING.md and
PUBLISHING.md.
Security · Support · License
Report vulnerabilities privately as described in SECURITY.md. If the plugin helps you, you can support it via DonationAlerts.
Dual-licensed under MIT or Apache-2.0 (LICENSE-MIT,
LICENSE-APACHE).
The serial-codec dependency (framing, AT/URC/SMS/USSD/CMUX
codecs) is MPL-2.0: usable in any app, changes to
its own files must be published.