| license | Apache-2.0 |
| name | rust-tauri-development |
| description | Expert Tauri v2 developer for building desktop apps with Rust backend and web frontend. Activate on: Tauri app, Tauri v2, Rust desktop app, IPC commands, tauri::command, tauri.conf.json, Tauri plugin, WebviewWindow, system tray Tauri, Tauri multi-window. NOT for: Electron apps (use cross-platform-desktop), code signing/distribution (use rust-app-distribution), pure Rust CLI tools (use rust-expert). |
| allowed-tools | Read,Write,Edit,Bash(cargo:*,npm:*,npx:*,pnpm:*,rustup:*),Glob,Grep |
| metadata | {"category":"Desktop & Native","tags":["tauri","rust","desktop","webview","ipc","native-app"],"pairs-with":[{"skill":"cross-platform-desktop","reason":"Platform-specific UI and behavior abstractions"},{"skill":"rust-app-distribution","reason":"Code signing, notarization, and distribution pipelines"},{"skill":"typescript-advanced-patterns","reason":"Type-safe frontend consuming Tauri IPC bridge"}]} |
| category | Frontend & UI |
| tags | ["rust","tauri","desktop","webview","cross-platform"] |
Rust Tauri Development
Expert Tauri v2 development for building desktop applications with Rust backend and web frontend.
DECISION POINTS
IPC Pattern Selection
Data Exchange Pattern:
├─ Request/Response needed?
│ ├─ YES: Use #[tauri::command]
│ │ ├─ Sync operation? → fn command() -> Result<T, String>
│ │ └─ I/O operation? → async fn command() -> Result<T, String>
│ └─ NO: Fire-and-forget?
│ ├─ YES: Use events (emit/listen)
│ └─ Large binary data? → Use raw payload channels
State Management Pattern:
├─ Simple shared data?
│ ├─ Read-only → Arc<T>
│ ├─ Mutable + sync access → Arc<Mutex<T>>
│ └─ Mutable + async access → Arc<RwLock<T>>
├─ Database needed?
│ ├─ Simple KV → tauri-plugin-store
│ └─ Relational → tauri-plugin-sql
└─ Cross-process state? → Database or file-based
Window Architecture
Window Count Decision:
├─ Single window app?
│ └─ Use default main window only
├─ Settings/preferences needed?
│ └─ Create secondary window with restricted capabilities
├─ Background processing?
│ ├─ System tray → TrayIconBuilder + hidden main window
│ └─ No tray → Keep main window, emit progress events
└─ Multi-document interface?
└─ Create window per document with shared state
Plugin vs Custom Code
Functionality needed:
├─ File system access?
│ ├─ Basic read/write → cargo tauri add fs
│ └─ Complex file ops → Custom commands + std::fs
├─ HTTP requests?
│ ├─ Simple → reqwest in custom commands
│ └─ Complex proxy/auth → Custom plugin
├─ Database?
│ ├─ SQLite/MySQL → cargo tauri add sql
│ └─ Custom storage → Custom plugin
└─ Platform integration?
├─ Notifications → cargo tauri add notification
└─ Custom system APIs → Custom plugin
FAILURE MODES
Thread Blocking Anti-Pattern
Detection Rule: If UI freezes during Rust command execution
Symptoms:
- Frontend becomes unresponsive
- Spinning cursor on macOS/Windows
- DevTools shows pending invoke() calls
Fix: Convert blocking command to async or spawn onto background thread
#[tauri::command]
fn heavy_computation() -> String {
std::thread::sleep(Duration::from_secs(5));
.()
}
() {
tokio::time::(Duration::()).;
.()
}