tauri-plugin-thermoprint
Tauri v2 plugin for thermal receipt printing with thermoprint.
Features
- List serial ports — discover connected printers
- Print raw ESC/POS bytes — send bytes directly to a serial port
- Print from JSON template — render a template and print in one call
- Chunked writes — avoids overflowing printer buffers
Setup
Rust side
Add to src-tauri/Cargo.toml:
[]
= { = "https://github.com/mouhamed1296/thermoprint" }
Register the plugin in src-tauri/src/main.rs:
JavaScript side
import from '@tauri-apps/api/core';
// List available serial ports
const ports = await ;
// → [{ name: "/dev/ttyUSB0", port_type: "USB (VID:0416 PID:5011 - POS Printer)" }]
// Build receipt bytes (using thermoprint WASM or template)
const bytes = ; // ESC/POS bytes
// Print to a serial port
await ;
// Or render a template and print in one shot
await ;
Commands
| Command | Description |
|---|---|
list_ports |
Returns PortInfo[] of available serial ports |
print_serial |
Send raw ESC/POS bytes to a serial port |
print_template |
Render a JSON template and print to a serial port |
License
MIT © Mamadou Sarr