Rust Desktop Applications
Overview
Rust has emerged as a premier language for building desktop applications that combine native performance with memory safety. The ecosystem offers two main approaches: Tauri for hybrid web UI + Rust backend apps (think Electron but 10x smaller and faster), and native GUI frameworks like egui, iced, and slint for pure Rust interfaces.
Tauri has revolutionized desktop development by enabling developers to use web technologies (React, Vue, Svelte) for the frontend while leveraging Rust's performance and safety for system-level operations. With bundle sizes under 5MB and memory usage 1/10th of Electron, Tauri apps deliver desktop-class performance. Native frameworks shine for specialized use cases: egui for immediate-mode tools and game editors, iced for Elm-style reactive apps, slint for embedded and declarative UIs.
This skill covers the complete Rust desktop development lifecycle from framework selection through architecture, state management, platform integration, and deployment. You'll build production-ready applications with proper IPC patterns, async runtime integration, native system access, and cross-platform distribution.
When to Use This Skill
Activate when building desktop applications that need native performance, small bundle sizes, system integration, or memory safety guarantees. Specifically use when:
- Building Electron alternatives with web UI + Rust backend (Tauri)
- Creating high-performance developer tools or productivity apps
- Developing system utilities requiring native OS integration
- Building cross-platform apps for Windows, macOS, and Linux
- Need <10MB bundle sizes vs 100MB+ Electron apps
- Implementing real-time applications (audio/video processing, games)
- Creating embedded GUI applications (kiosks, IoT devices)
Don't Use When
- Simple web apps - Use Next.js, Vite, or web frameworks
- Mobile-first applications - Use Flutter, React Native, or Kotlin Multiplatform
- Purely CLI tools - Use clap/structopt for command-line apps
- Browser extensions - Use WebExtensions API
- Quick prototypes - Native development has setup overhead
- Team lacks Rust experience - Steep learning curve for system programming
The Iron Law
TAURI FOR WEB UI + RUST BACKEND | NATIVE GUI FOR PURE RUST | NEVER MIX BUSINESS LOGIC IN FRONTEND
Duplicating logic between frontend and backend, or bypassing IPC for direct access, violates architecture.
Core Principles
- Framework Alignment: Tauri for web-skilled teams, native GUI for Rust-first projects
- Clear Separation: Frontend handles UI, Rust backend handles business logic and system access
- Type-Safe IPC: Commands and events strongly typed with serde serialization
- Async Runtime: Tokio for backend concurrency, prevent blocking main thread
- Security First: Validate all IPC inputs, minimize exposed commands, CSP policies
- Platform Abstraction: Write once, handle platform differences gracefully
Quick Start
Choose Your Framework
- Tauri: Have web skills (React/Vue/Svelte)? Want rapid UI development? →
cargo install tauri-cli
- Native GUI: Pure Rust project? Immediate mode or reactive patterns? → Choose egui/iced/slint
Initialize Project
# Tauri
cargo create-tauri-app my-app
# Select: npm, React/Vue/Svelte, TypeScript
# Native (egui example)
cargo new my-app
cargo add eframe egui
Setup Architecture
- Tauri: Define commands in
src-tauri/src/main.rs, handle IPC
- Native: Implement app state, event loop, and UI update logic
- Structure:
src/ (backend), ui/ or src-ui/ (frontend if Tauri)
Implement Core Features
- Define Tauri commands with
#[tauri::command]
- Setup state management (Arc<Mutex> or channels)
- Integrate Tokio for async operations
- Add error handling with
Result<T, E>
Add Platform Integration
- File system access (dialogs, read/write)
- System tray, notifications, auto-updates
- Deep linking, custom URL schemes
- OS-specific features (Windows registry, macOS sandboxing)
Build and Distribute
# Development
cargo tauri dev # or cargo run
# Production build
cargo tauri build # Creates installers for current platform
# Cross-platform: Use GitHub Actions with matrix builds
Framework Decision Tree
Need desktop app?
├─ Have web frontend skills (React/Vue/Svelte)?
│ └─ YES → Use Tauri
│ ├─ Need <5MB bundles? ✓
│ ├─ System integration? ✓
│ ├─ Cross-platform? ✓
│ └─ Rapid UI development? ✓
│
└─ Pure Rust, no web frontend?
├─ Game editor or immediate mode tools? → egui
├─ Elm-style reactive architecture? → iced
├─ Declarative UI, embedded devices? → slint
└─ Data-first reactive? → druid
Tauri when: Web UI expertise, need modern frontend frameworks, rapid iteration
Native when: Maximum performance, no web dependencies, specialized UI patterns
Navigation
Detailed guides available:
- Tauri Framework: Complete Tauri architecture, project setup, IPC communication patterns, native API access, configuration, security model, and build process with real-world examples
- Native GUI Frameworks: Deep dive into egui, iced, druid, and slint - architecture patterns, when to use each, comparison matrix, and production code examples
- Architecture Patterns: Desktop-specific patterns including MVC/MVVM, command pattern, event-driven architecture, plugin systems, resource management, and error handling strategies
- State Management: State management strategies, async runtime integration with Tokio, message passing, reactive patterns, persistence (configs/databases), and multi-window state sharing
- Platform Integration: File system access, system tray, notifications, auto-updates, deep linking, OS-specific features (Windows/macOS/Linux), permissions, and security
- Testing & Deployment: Integration testing, UI testing approaches, cross-compilation, platform-specific builds, distribution (installers/bundles/stores), signing, notarization, and CI/CD pipelines
Key Patterns
Correct Tauri Pattern:
✅ Commands in Rust backend
✅ Type-safe IPC with serde
✅ Async operations with Tokio
✅ State management with Arc<Mutex<T>>
✅ Error propagation with Result<T, E>
✅ Frontend calls backend via invoke()
Correct Native GUI Pattern:
✅ Immediate mode (egui) or retained mode (iced)
✅ State updates trigger redraws
✅ Event handling in Rust
✅ Platform-agnostic rendering
✅ Resource cleanup on drop
Incorrect Patterns:
❌ Business logic in frontend JavaScript
❌ Exposing unsafe commands without validation
❌ Blocking operations on main thread
❌ Direct filesystem access from frontend
❌ Missing error handling on IPC
❌ Hardcoded platform-specific paths
Red Flags - STOP
- Blocking the main thread - Use Tokio spawn for long operations
- Exposing sensitive commands - Validate, rate limit, minimize surface area
- Missing CSP in Tauri - Configure Content Security Policy
- No input validation - Always validate IPC command arguments
- Direct frontend file access - Use Tauri file system APIs
- Ignoring platform differences - Test on all target platforms
- Large bundle sizes - Profile and optimize dependencies
- No auto-update strategy - Users won't manually update
Integration with Other Skills
- vite-local-dev: Integrate Vite with Tauri for hot module replacement and fast frontend builds
- async-testing: Test async Tokio code in Tauri commands and background tasks
- performance-profiling: Profile Rust backend with Criterion, flamegraphs for optimization
- test-driven-development: Write tests for commands, state management, and business logic
- verification-before-completion: Test cross-platform builds before shipping
- systematic-debugging: Debug Tauri IPC issues, inspect console logs, use Rust debugger
Real-World Impact
Performance Metrics:
- Bundle size: 3-5MB (Tauri) vs 100-200MB (Electron)
- Memory usage: 50-100MB (Tauri) vs 500MB-1GB (Electron)
- Startup time: <1s (Tauri) vs 3-5s (Electron)
- Build time: 1-2 min (Tauri) vs 5-10 min (Electron)
Production Examples:
- Warp Terminal: High-performance terminal built with Rust (egui/custom)
- Lapce: Fast code editor using Druid (later custom framework)
- Zed: Collaborative code editor with native Rust UI
- Notion-like apps: Using Tauri for desktop versions
- System utilities: File managers, task managers, monitoring tools
The Bottom Line
Rust desktop development offers unmatched performance with memory safety.
Choose Tauri for web UI + Rust backend with tiny bundles. Choose native GUI for pure Rust with specialized patterns. Architect with clear frontend/backend separation. Use type-safe IPC. Integrate Tokio for async. Handle platform differences. Test cross-platform early.
This is the Rust desktop way.
1---2name: rust-desktop-applications3description: Build cross-platform desktop applications with Rust using Tauri framework and native GUI alternatives4license: MIT5---6
7# Rust Desktop Applications
8
9## Overview
10
11Rust has emerged as a premier language for building desktop applications that combine native performance with memory safety. The ecosystem offers two main approaches: **Tauri** for hybrid web UI + Rust backend apps (think Electron but 10x smaller and faster), and **native GUI frameworks** like egui, iced, and slint for pure Rust interfaces.
12
13Tauri has revolutionized desktop development by enabling developers to use web technologies (React, Vue, Svelte) for the frontend while leveraging Rust's performance and safety for system-level operations. With bundle sizes under 5MB and memory usage 1/10th of Electron, Tauri apps deliver desktop-class performance. Native frameworks shine for specialized use cases: egui for immediate-mode tools and game editors, iced for Elm-style reactive apps, slint for embedded and declarative UIs.
14
15This skill covers the complete Rust desktop development lifecycle from framework selection through architecture, state management, platform integration, and deployment. You'll build production-ready applications with proper IPC patterns, async runtime integration, native system access, and cross-platform distribution.
16
17## When to Use This Skill
18
19Activate when building desktop applications that need **native performance**, **small bundle sizes**, **system integration**, or **memory safety guarantees**. Specifically use when:
20
21- Building Electron alternatives with web UI + Rust backend (Tauri)
22- Creating high-performance developer tools or productivity apps
23- Developing system utilities requiring native OS integration
24- Building cross-platform apps for Windows, macOS, and Linux
25- Need <10MB bundle sizes vs 100MB+ Electron apps
26- Implementing real-time applications (audio/video processing, games)
27- Creating embedded GUI applications (kiosks, IoT devices)
28
29## Don't Use When
30
31- **Simple web apps** - Use Next.js, Vite, or web frameworks
32- **Mobile-first applications** - Use Flutter, React Native, or Kotlin Multiplatform
33- **Purely CLI tools** - Use clap/structopt for command-line apps
34- **Browser extensions** - Use WebExtensions API
35- **Quick prototypes** - Native development has setup overhead
36- **Team lacks Rust experience** - Steep learning curve for system programming
37
38## The Iron Law
39
40**TAURI FOR WEB UI + RUST BACKEND | NATIVE GUI FOR PURE RUST | NEVER MIX BUSINESS LOGIC IN FRONTEND**
41
42Duplicating logic between frontend and backend, or bypassing IPC for direct access, violates architecture.
43
44## Core Principles
45
461. **Framework Alignment**: Tauri for web-skilled teams, native GUI for Rust-first projects
472. **Clear Separation**: Frontend handles UI, Rust backend handles business logic and system access
483. **Type-Safe IPC**: Commands and events strongly typed with serde serialization
494. **Async Runtime**: Tokio for backend concurrency, prevent blocking main thread
505. **Security First**: Validate all IPC inputs, minimize exposed commands, CSP policies
516. **Platform Abstraction**: Write once, handle platform differences gracefully
52
53## Quick Start
54
551. **Choose Your Framework**
56 - **Tauri**: Have web skills (React/Vue/Svelte)? Want rapid UI development? → `cargo install tauri-cli`
57 - **Native GUI**: Pure Rust project? Immediate mode or reactive patterns? → Choose egui/iced/slint
58
592. **Initialize Project**
60 ```bash
61 # Tauri
62 cargo create-tauri-app my-app
63 # Select: npm, React/Vue/Svelte, TypeScript
64
65 # Native (egui example)
66 cargo new my-app
67 cargo add eframe egui
68 ```
69
703. **Setup Architecture**
71 - Tauri: Define commands in `src-tauri/src/main.rs`, handle IPC
72 - Native: Implement app state, event loop, and UI update logic
73 - Structure: `src/` (backend), `ui/` or `src-ui/` (frontend if Tauri)
74
754. **Implement Core Features**
76 - Define Tauri commands with `#[tauri::command]`
77 - Setup state management (Arc<Mutex<T>> or channels)
78 - Integrate Tokio for async operations
79 - Add error handling with `Result<T, E>`
80
815. **Add Platform Integration**
82 - File system access (dialogs, read/write)
83 - System tray, notifications, auto-updates
84 - Deep linking, custom URL schemes
85 - OS-specific features (Windows registry, macOS sandboxing)
86
876. **Build and Distribute**
88 ```bash
89 # Development
90 cargo tauri dev # or cargo run
91
92 # Production build
93 cargo tauri build # Creates installers for current platform
94
95 # Cross-platform: Use GitHub Actions with matrix builds
96 ```
97
98## Framework Decision Tree
99
100```
101Need desktop app?
102├─ Have web frontend skills (React/Vue/Svelte)?
103│ └─ YES → Use Tauri
104│ ├─ Need <5MB bundles? ✓
105│ ├─ System integration? ✓
106│ ├─ Cross-platform? ✓
107│ └─ Rapid UI development? ✓
108│
109└─ Pure Rust, no web frontend?
110 ├─ Game editor or immediate mode tools? → egui
111 ├─ Elm-style reactive architecture? → iced
112 ├─ Declarative UI, embedded devices? → slint
113 └─ Data-first reactive? → druid
114```
115
116**Tauri when**: Web UI expertise, need modern frontend frameworks, rapid iteration
117**Native when**: Maximum performance, no web dependencies, specialized UI patterns
118
119## Navigation
120
121Detailed guides available:
122
123- **[Tauri Framework](references/tauri-framework.md)**: Complete Tauri architecture, project setup, IPC communication patterns, native API access, configuration, security model, and build process with real-world examples
124- **[Native GUI Frameworks](references/native-gui-frameworks.md)**: Deep dive into egui, iced, druid, and slint - architecture patterns, when to use each, comparison matrix, and production code examples
125- **[Architecture Patterns](references/architecture-patterns.md)**: Desktop-specific patterns including MVC/MVVM, command pattern, event-driven architecture, plugin systems, resource management, and error handling strategies
126- **[State Management](references/state-management.md)**: State management strategies, async runtime integration with Tokio, message passing, reactive patterns, persistence (configs/databases), and multi-window state sharing
127- **[Platform Integration](references/platform-integration.md)**: File system access, system tray, notifications, auto-updates, deep linking, OS-specific features (Windows/macOS/Linux), permissions, and security
128- **[Testing & Deployment](references/testing-deployment.md)**: Integration testing, UI testing approaches, cross-compilation, platform-specific builds, distribution (installers/bundles/stores), signing, notarization, and CI/CD pipelines
129
130## Key Patterns
131
132**Correct Tauri Pattern:**
133```rust
134✅ Commands in Rust backend
135✅ Type-safe IPC with serde
136✅ Async operations with Tokio
137✅ State management with Arc<Mutex<T>>
138✅ Error propagation with Result<T, E>
139✅ Frontend calls backend via invoke()
140```
141
142**Correct Native GUI Pattern:**
143```rust
144✅ Immediate mode (egui) or retained mode (iced)
145✅ State updates trigger redraws
146✅ Event handling in Rust
147✅ Platform-agnostic rendering
148✅ Resource cleanup on drop
149```
150
151**Incorrect Patterns:**
152```rust
153❌ Business logic in frontend JavaScript
154❌ Exposing unsafe commands without validation
155❌ Blocking operations on main thread
156❌ Direct filesystem access from frontend
157❌ Missing error handling on IPC
158❌ Hardcoded platform-specific paths
159```
160
161## Red Flags - STOP
162
163- **Blocking the main thread** - Use Tokio spawn for long operations
164- **Exposing sensitive commands** - Validate, rate limit, minimize surface area
165- **Missing CSP in Tauri** - Configure Content Security Policy
166- **No input validation** - Always validate IPC command arguments
167- **Direct frontend file access** - Use Tauri file system APIs
168- **Ignoring platform differences** - Test on all target platforms
169- **Large bundle sizes** - Profile and optimize dependencies
170- **No auto-update strategy** - Users won't manually update
171
172## Integration with Other Skills
173
174- **vite-local-dev**: Integrate Vite with Tauri for hot module replacement and fast frontend builds
175- **async-testing**: Test async Tokio code in Tauri commands and background tasks
176- **performance-profiling**: Profile Rust backend with Criterion, flamegraphs for optimization
177- **test-driven-development**: Write tests for commands, state management, and business logic
178- **verification-before-completion**: Test cross-platform builds before shipping
179- **systematic-debugging**: Debug Tauri IPC issues, inspect console logs, use Rust debugger
180
181## Real-World Impact
182
183**Performance Metrics:**
184- Bundle size: 3-5MB (Tauri) vs 100-200MB (Electron)
185- Memory usage: 50-100MB (Tauri) vs 500MB-1GB (Electron)
186- Startup time: <1s (Tauri) vs 3-5s (Electron)
187- Build time: 1-2 min (Tauri) vs 5-10 min (Electron)
188
189**Production Examples:**
190- **Warp Terminal**: High-performance terminal built with Rust (egui/custom)
191- **Lapce**: Fast code editor using Druid (later custom framework)
192- **Zed**: Collaborative code editor with native Rust UI
193- **Notion-like apps**: Using Tauri for desktop versions
194- **System utilities**: File managers, task managers, monitoring tools
195
196## The Bottom Line
197
198**Rust desktop development offers unmatched performance with memory safety.**
199
200Choose Tauri for web UI + Rust backend with tiny bundles. Choose native GUI for pure Rust with specialized patterns. Architect with clear frontend/backend separation. Use type-safe IPC. Integrate Tokio for async. Handle platform differences. Test cross-platform early.
201
202This is the Rust desktop way.