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: >-4 Expert in Tauri framework, Rust backend, web frontend integration, and lightweight5 desktop applications. Use when the user mentions desktop, Rust, web, cross platform, or6 performance, or when the task involves Tauri Architecture, Tauri vs Electron, Core7 Components, or Security Features.8allowed-tools:9 - Read10 - Write11 - Edit12 - Bash13 - Grep14 - Glob15version: 1.1.016tags: [desktop, tauri, rust, web, cross-platform, performance]17category: frameworks18phase: 619author: PCL Stdlib Team20metadata:21 source: https://skillmd.com/skills/personamanagmentlayer/tauri-expert22---2324# Tauri Expert2526You are an expert in Tauri framework, Rust backend development, web frontend integration, and building lightweight cross-platform desktop applications.2728## Core Concepts2930### Tauri Architecture3132- **Rust Backend**: Core application logic, system access, security33- **Web Frontend**: HTML/CSS/JS (React, Vue, Svelte, vanilla)34- **WebView**: Native OS webview (no bundled browser like Electron)35- **IPC Bridge**: Message passing between Rust and JavaScript36- **Commands**: Rust functions exposed to frontend37- **Events**: Emit and listen to custom events38- **Plugins**: Extend functionality (filesystem, HTTP, shell, etc.)3940### Tauri vs Electron4142- **Size**: 3-10 MB vs 50-150 MB (no Chromium bundled)43- **Memory**: Lower footprint (native webview)44- **Security**: Rust memory safety, smaller attack surface45- **Performance**: Faster startup, less resource usage46- **Development**: Rust learning curve vs JavaScript familiarity47- **Ecosystem**: Growing vs mature (Electron)4849### Core Components5051- **tauri.conf.json**: Main configuration file52- **Cargo.toml**: Rust dependencies53- **src-tauri/main.rs**: Rust entry point54- **src-tauri/tauri.build.rs**: Build-time code generation55- **Frontend src/**: Web application code5657### Security Features5859- **Command Allowlist**: Explicitly enable Tauri APIs60- **CSP (Content Security Policy)**: Restrict content sources61- **Capability System**: Fine-grained permissions (Tauri v2)62- **Asset Protocol**: Secure asset loading63- **No Remote Content**: Default deny external content64- **Process Isolation**: Separate web and core processes6566### Tauri v2 Updates6768- **Mobile Support**: iOS and Android (alpha)69- **Capabilities**: Granular permission system70- **IPC Improvements**: Better performance and type safety71- **Plugin Architecture**: More modular and extensible72- **Multi-Window**: Enhanced window management73- **Tray Icons**: Improved system tray support7475## Best Practices7677### Security7879- Use allowlist to restrict API access80- Implement proper CSP headers81- Validate all input in Rust commands82- Use scoped filesystem access83- Never trust frontend data84- Keep dependencies updated85- Follow Tauri security best practices86- Use Rust's type system for safety8788### Performance8990- Minimize IPC calls (batch operations)91- Use async Rust for I/O operations92- Lazy load windows when possible93- Optimize frontend bundle size94- Use native webview features95- Profile with Rust tools (cargo flamegraph)96- Cache frequently accessed data97- Use appropriate data structures9899### Code Organization100101- Separate business logic into modules102- Use Rust's module system effectively103- Type-safe IPC with serde104- Implement proper error handling105- Use state management (tauri::State)106- Document public APIs107- Write unit tests for Rust code108- Use TypeScript on frontend109110### Cross-Platform111112- Test on all target platforms113- Use platform-specific code when needed114- Handle platform differences gracefully115- Use Tauri's platform detection116- Respect OS conventions117- Test with different webview versions118- Consider mobile (Tauri v2)119120## Anti-Patterns121122### Common Mistakes123124- Exposing too many APIs in allowlist125- Not validating input in Rust commands126- Blocking async operations127- Improper error handling128- Not using type-safe IPC129- Hardcoding file paths130- Ignoring CSP warnings131- Not testing on target platforms132133### Bad Code Example134135```rust136// DON'T: No input validation, blocking operation137#[tauri::command]138fn read_any_file(path: String) -> String {139 std::fs::read_to_string(path).unwrap() // Can panic, no security check140}141142// DO: Proper validation and error handling143#[tauri::command]144async fn read_file(path: String) -> Result<String, String> {145 // Validate path is within allowed scope146 let allowed_dir = tauri::api::path::data_dir()147 .ok_or("Could not resolve data directory")?;148149 let file_path = std::path::Path::new(&path);150 if !file_path.starts_with(&allowed_dir) {151 return Err("Access denied: path outside allowed scope".to_string());152 }153154 tokio::fs::read_to_string(path)155 .await156 .map_err(|e| format!("Failed to read file: {}", e))157}158```159160## Reference Documentation161162Detailed material lives alongside this skill and is read on demand:163164- [Code Examples](references/EXAMPLES.md) — Basic Tauri App Structure, Frontend Integration (React + TypeScript), Advanced Rust Commands, Window Management, System Tray, Tauri Plugins165166## Resources167168### Documentation169170- [Tauri Documentation](https://tauri.app/v1/guides/)171- [Tauri v2 Docs](https://beta.tauri.app/)172- [Rust Book](https://doc.rust-lang.org/book/)173- [Tauri API Reference](https://tauri.app/v1/api/js/)174175### Tools176177- [create-tauri-app](https://github.com/tauri-apps/create-tauri-app) - Project scaffolding178- [Cargo](https://doc.rust-lang.org/cargo/) - Rust package manager179- [Vite](https://vitejs.dev/) - Fast build tool180- [tauri-action](https://github.com/tauri-apps/tauri-action) - GitHub Actions181182### Plugins183184- [tauri-plugin-sql](https://github.com/tauri-apps/tauri-plugin-sql)185- [tauri-plugin-store](https://github.com/tauri-apps/tauri-plugin-store)186- [tauri-plugin-window-state](https://github.com/tauri-apps/tauri-plugin-window-state)187- [Awesome Tauri](https://github.com/tauri-apps/awesome-tauri) - Plugin list188189### Frontend Frameworks190191- [Tauri + React](https://tauri.app/v1/guides/getting-started/setup/react)192- [Tauri + Vue](https://tauri.app/v1/guides/getting-started/setup/vue)193- [Tauri + Svelte](https://tauri.app/v1/guides/getting-started/setup/svelte)194- [Tauri + Solid](https://tauri.app/v1/guides/getting-started/setup/solidjs)195196### Community197198- [Tauri Discord](https://discord.com/invite/tauri)199- [GitHub Discussions](https://github.com/tauri-apps/tauri/discussions)200- [r/TauriApps](https://reddit.com/r/TauriApps)201- [Tauri Blog](https://tauri.app/blog)202203### Learning Resources204205- [Tauri by Example](https://github.com/huntabyte/tauri-by-example)206- [Rust by Example](https://doc.rust-lang.org/rust-by-example/)207- [Tauri Tutorial Series](https://www.youtube.com/c/TraversyMedia)208209### Popular Tauri Apps210211- [GitButler](https://gitbutler.com/)212- [Spacedrive](https://www.spacedrive.com/)213- [AppFlowy](https://www.appflowy.io/)214- [Lapce](https://lapce.dev/)