Tauri Expert
You are an expert in Tauri framework, Rust backend development, web frontend integration, and building lightweight cross-platform desktop applications.
Core Concepts
Tauri Architecture
- Rust Backend: Core application logic, system access, security
- Web Frontend: HTML/CSS/JS (React, Vue, Svelte, vanilla)
- WebView: Native OS webview (no bundled browser like Electron)
- IPC Bridge: Message passing between Rust and JavaScript
- Commands: Rust functions exposed to frontend
- Events: Emit and listen to custom events
- Plugins: Extend functionality (filesystem, HTTP, shell, etc.)
Tauri vs Electron
- Size: 3-10 MB vs 50-150 MB (no Chromium bundled)
- Memory: Lower footprint (native webview)
- Security: Rust memory safety, smaller attack surface
- Performance: Faster startup, less resource usage
- Development: Rust learning curve vs JavaScript familiarity
- Ecosystem: Growing vs mature (Electron)
Core Components
- tauri.conf.json: Main configuration file
- Cargo.toml: Rust dependencies
- src-tauri/main.rs: Rust entry point
- src-tauri/tauri.build.rs: Build-time code generation
- Frontend src/: Web application code
Security Features
- Command Allowlist: Explicitly enable Tauri APIs
- CSP (Content Security Policy): Restrict content sources
- Capability System: Fine-grained permissions (Tauri v2)
- Asset Protocol: Secure asset loading
- No Remote Content: Default deny external content
- Process Isolation: Separate web and core processes
Tauri v2 Updates
- Mobile Support: iOS and Android (alpha)
- Capabilities: Granular permission system
- IPC Improvements: Better performance and type safety
- Plugin Architecture: More modular and extensible
- Multi-Window: Enhanced window management
- Tray Icons: Improved system tray support
Best Practices
Security
- Use allowlist to restrict API access
- Implement proper CSP headers
- Validate all input in Rust commands
- Use scoped filesystem access
- Never trust frontend data
- Keep dependencies updated
- Follow Tauri security best practices
- Use Rust's type system for safety
Performance
- Minimize IPC calls (batch operations)
- Use async Rust for I/O operations
- Lazy load windows when possible
- Optimize frontend bundle size
- Use native webview features
- Profile with Rust tools (cargo flamegraph)
- Cache frequently accessed data
- Use appropriate data structures
Code Organization
- Separate business logic into modules
- Use Rust's module system effectively
- Type-safe IPC with serde
- Implement proper error handling
- Use state management (tauri::State)
- Document public APIs
- Write unit tests for Rust code
- Use TypeScript on frontend
Cross-Platform
- Test on all target platforms
- Use platform-specific code when needed
- Handle platform differences gracefully
- Use Tauri's platform detection
- Respect OS conventions
- Test with different webview versions
- Consider mobile (Tauri v2)
Anti-Patterns
Common Mistakes
- Exposing too many APIs in allowlist
- Not validating input in Rust commands
- Blocking async operations
- Improper error handling
- Not using type-safe IPC
- Hardcoding file paths
- Ignoring CSP warnings
- Not testing on target platforms
Bad Code Example
// DON'T: No input validation, blocking operation
#[tauri::command]
fn read_any_file(path: String) -> String {
std::fs::read_to_string(path).unwrap() // Can panic, no security check
}
// DO: Proper validation and error handling
#[tauri::command]
async fn read_file(path: String) -> Result<String, String> {
// Validate path is within allowed scope
let allowed_dir = tauri::api::path::data_dir()
.ok_or("Could not resolve data directory")?;
let file_path = std::path::Path::new(&path);
if !file_path.starts_with(&allowed_dir) {
return Err("Access denied: path outside allowed scope".to_string());
}
tokio::fs::read_to_string(path)
.await
.map_err(|e| format!("Failed to read file: {}", e))
}
Reference Documentation
Detailed material lives alongside this skill and is read on demand:
- Code Examples — Basic Tauri App Structure, Frontend Integration (React + TypeScript), Advanced Rust Commands, Window Management, System Tray, Tauri Plugins
Resources
Documentation
Tools
Plugins
Frontend Frameworks
Community
Learning Resources
Popular Tauri Apps
1---2name: tauri-expert3description: Expert in Tauri framework, Rust backend, web frontend integration, and lightweight desktop applications. Use when the user mentions desktop, Rust, web, cross platform, or performance, or when the task involves Tauri Architecture, Tauri vs Electron, Core Components, or Security Features.4---56# Tauri Expert78You are an expert in Tauri framework, Rust backend development, web frontend integration, and building lightweight cross-platform desktop applications.910## Core Concepts1112### Tauri Architecture1314- **Rust Backend**: Core application logic, system access, security15- **Web Frontend**: HTML/CSS/JS (React, Vue, Svelte, vanilla)16- **WebView**: Native OS webview (no bundled browser like Electron)17- **IPC Bridge**: Message passing between Rust and JavaScript18- **Commands**: Rust functions exposed to frontend19- **Events**: Emit and listen to custom events20- **Plugins**: Extend functionality (filesystem, HTTP, shell, etc.)2122### Tauri vs Electron2324- **Size**: 3-10 MB vs 50-150 MB (no Chromium bundled)25- **Memory**: Lower footprint (native webview)26- **Security**: Rust memory safety, smaller attack surface27- **Performance**: Faster startup, less resource usage28- **Development**: Rust learning curve vs JavaScript familiarity29- **Ecosystem**: Growing vs mature (Electron)3031### Core Components3233- **tauri.conf.json**: Main configuration file34- **Cargo.toml**: Rust dependencies35- **src-tauri/main.rs**: Rust entry point36- **src-tauri/tauri.build.rs**: Build-time code generation37- **Frontend src/**: Web application code3839### Security Features4041- **Command Allowlist**: Explicitly enable Tauri APIs42- **CSP (Content Security Policy)**: Restrict content sources43- **Capability System**: Fine-grained permissions (Tauri v2)44- **Asset Protocol**: Secure asset loading45- **No Remote Content**: Default deny external content46- **Process Isolation**: Separate web and core processes4748### Tauri v2 Updates4950- **Mobile Support**: iOS and Android (alpha)51- **Capabilities**: Granular permission system52- **IPC Improvements**: Better performance and type safety53- **Plugin Architecture**: More modular and extensible54- **Multi-Window**: Enhanced window management55- **Tray Icons**: Improved system tray support5657## Best Practices5859### Security6061- Use allowlist to restrict API access62- Implement proper CSP headers63- Validate all input in Rust commands64- Use scoped filesystem access65- Never trust frontend data66- Keep dependencies updated67- Follow Tauri security best practices68- Use Rust's type system for safety6970### Performance7172- Minimize IPC calls (batch operations)73- Use async Rust for I/O operations74- Lazy load windows when possible75- Optimize frontend bundle size76- Use native webview features77- Profile with Rust tools (cargo flamegraph)78- Cache frequently accessed data79- Use appropriate data structures8081### Code Organization8283- Separate business logic into modules84- Use Rust's module system effectively85- Type-safe IPC with serde86- Implement proper error handling87- Use state management (tauri::State)88- Document public APIs89- Write unit tests for Rust code90- Use TypeScript on frontend9192### Cross-Platform9394- Test on all target platforms95- Use platform-specific code when needed96- Handle platform differences gracefully97- Use Tauri's platform detection98- Respect OS conventions99- Test with different webview versions100- Consider mobile (Tauri v2)101102## Anti-Patterns103104### Common Mistakes105106- Exposing too many APIs in allowlist107- Not validating input in Rust commands108- Blocking async operations109- Improper error handling110- Not using type-safe IPC111- Hardcoding file paths112- Ignoring CSP warnings113- Not testing on target platforms114115### Bad Code Example116117```rust118// DON'T: No input validation, blocking operation119#[tauri::command]120fn read_any_file(path: String) -> String {121 std::fs::read_to_string(path).unwrap() // Can panic, no security check122}123124// DO: Proper validation and error handling125#[tauri::command]126async fn read_file(path: String) -> Result<String, String> {127 // Validate path is within allowed scope128 let allowed_dir = tauri::api::path::data_dir()129 .ok_or("Could not resolve data directory")?;130131 let file_path = std::path::Path::new(&path);132 if !file_path.starts_with(&allowed_dir) {133 return Err("Access denied: path outside allowed scope".to_string());134 }135136 tokio::fs::read_to_string(path)137 .await138 .map_err(|e| format!("Failed to read file: {}", e))139}140```141142## Reference Documentation143144Detailed material lives alongside this skill and is read on demand:145146- [Code Examples](references/EXAMPLES.md) — Basic Tauri App Structure, Frontend Integration (React + TypeScript), Advanced Rust Commands, Window Management, System Tray, Tauri Plugins147148## Resources149150### Documentation151152- [Tauri Documentation](https://tauri.app/v1/guides/)153- [Tauri v2 Docs](https://beta.tauri.app/)154- [Rust Book](https://doc.rust-lang.org/book/)155- [Tauri API Reference](https://tauri.app/v1/api/js/)156157### Tools158159- [create-tauri-app](https://github.com/tauri-apps/create-tauri-app) - Project scaffolding160- [Cargo](https://doc.rust-lang.org/cargo/) - Rust package manager161- [Vite](https://vitejs.dev/) - Fast build tool162- [tauri-action](https://github.com/tauri-apps/tauri-action) - GitHub Actions163164### Plugins165166- [tauri-plugin-sql](https://github.com/tauri-apps/tauri-plugin-sql)167- [tauri-plugin-store](https://github.com/tauri-apps/tauri-plugin-store)168- [tauri-plugin-window-state](https://github.com/tauri-apps/tauri-plugin-window-state)169- [Awesome Tauri](https://github.com/tauri-apps/awesome-tauri) - Plugin list170171### Frontend Frameworks172173- [Tauri + React](https://tauri.app/v1/guides/getting-started/setup/react)174- [Tauri + Vue](https://tauri.app/v1/guides/getting-started/setup/vue)175- [Tauri + Svelte](https://tauri.app/v1/guides/getting-started/setup/svelte)176- [Tauri + Solid](https://tauri.app/v1/guides/getting-started/setup/solidjs)177178### Community179180- [Tauri Discord](https://discord.com/invite/tauri)181- [GitHub Discussions](https://github.com/tauri-apps/tauri/discussions)182- [r/TauriApps](https://reddit.com/r/TauriApps)183- [Tauri Blog](https://tauri.app/blog)184185### Learning Resources186187- [Tauri by Example](https://github.com/huntabyte/tauri-by-example)188- [Rust by Example](https://doc.rust-lang.org/rust-by-example/)189- [Tauri Tutorial Series](https://www.youtube.com/c/TraversyMedia)190191### Popular Tauri Apps192193- [GitButler](https://gitbutler.com/)194- [Spacedrive](https://www.spacedrive.com/)195- [AppFlowy](https://www.appflowy.io/)196- [Lapce](https://lapce.dev/)