Skip to main content
< All Topics
Print

Tauri Desktop Development

name: tauri-desktop-development

description: Tauri 2 desktop application development with Rust backend, React/TypeScript frontend, SQLite persistence, and multi-platform builds. Use when building Tauri apps, implementing Rust IPC commands, managing desktop app state, or targeting macOS/iOS/Windows from a single codebase.

Tauri Desktop Development

Instructions

Build performant, secure desktop applications with Tauri 2.

Rust backend:

  • Define IPC commands with #[tauri::command] — these are the bridge between frontend and native code
  • Use tauri::State for shared application state accessible from any command
  • Persist data with rusqlite: open the database in setup(), wrap the connection in Mutex, and pass as managed state
  • Use tokio for async operations; mark commands as async when performing I/O

React/TypeScript frontend:

  • Call Rust commands via invoke('command_name', { args }) from @tauri-apps/api/core
  • Use the event system (listen, emit) for backend-to-frontend push notifications
  • Manage frontend state with Zustand — lightweight stores that pair well with Tauri’s command-based data flow
  • Structure the frontend as a standard React app: components, hooks, stores, and pages

Plugin architecture:

  • Use tauri-plugin-* crates for common needs: tauri-plugin-shell, tauri-plugin-fs, tauri-plugin-dialog
  • Register plugins in tauri::Builder::default().plugin(tauri_plugin_shell::init())
  • Prefer official plugins over custom native code for maintainability and cross-platform compatibility

Multi-platform builds:

  • macOS: builds produce .dmg and .app bundles; sign with Apple Developer ID for distribution
  • iOS: use tauri ios init and tauri ios dev for Xcode project generation and simulator testing
  • Windows: builds produce .msi and .exe installers via WiX or NSIS
  • Set platform-specific configuration in tauri.conf.json under the bundle section

Security:

  • Capability-based permissions: define allowed commands and scopes in src-tauri/capabilities/*.json
  • Each window gets an explicit set of permitted IPC commands — deny by default
  • Set Content Security Policy headers in tauri.conf.json to restrict script and resource origins
  • Never expose filesystem or shell access without scoped permissions

Antigravity testing for Tauri apps:

Antigravity’s browser sub-agent cannot directly control native desktop windows. For Tauri apps:

  • Use the Tauri dev build (cargo tauri dev) which renders in a webview — the browser sub-agent can test web content inside the webview if accessible at a local URL
  • For truly native UI elements (title bar, system dialogs), test manually
  • Use Antigravity’s code agent (not browser agent) for Rust backend logic testing — dispatch a targeted debug session to trace IPC command behavior
  • The “Native App QA” prompt in .agents/workflows/prompt-library.md provides the recommended dispatch pattern for Tauri projects

See the antigravity-testing skill for agent dispatch and the antigravity-debugging skill for Rust backend debugging.

Reference architectures:

  • Personal Assistant: full-featured Tauri 2 app with 86+ agents, SQLite backend, React UI with Zustand, plugin-based extensibility
  • Estate Manager: Electron + Tauri dual-stack demonstrating migration path from Electron to Tauri for native performance
Table of Contents