@tauri-development

Build, debug, or package Tauri v2 desktop apps. Trace frontend calls through Rust commands, scope window permissions, and verify the packaged app.

Tauri Development

When to Use

  • Add or debug Rust commands, managed state, or native features in a Tauri desktop app.
  • Review which windows or webviews can call native commands and plugins.
  • Diagnose a feature that works in development but fails in an installer, an installed build, or an update.

Prerequisites

Identify the Tauri major version, package manager, Rust toolchain, target OS and architecture, and the affected window and user action. Inspect the frontend dependencies, src-tauri/Cargo.toml, Tauri configuration, and active capability definitions. Use the project's lockfiles and target prerequisites. For an explicit v1-to-v2 upgrade, inventory the old APIs and allowlist before applying the official migration guide.

Trace the frontend-to-Rust contract

  1. Follow the UI action to the v2 invoke from @tauri-apps/api/core, the command in tauri::generate_handler!, and the native state or OS call. Check the command name, required and optional inputs, serialized outputs, and rejection handling.
  2. Tauri command arguments use camelCase keys by default. Check for a command-level rename_all override and serialize Rust return values intentionally. The TypeScript generic on invoke<T> describes the expected output. Verify it against the command response.
  3. Validate input and enforce application-specific authorization in Rust. Return structured errors the UI can act on. Use managed state for shared native values, keep lock scopes small, and offload blocking work from the UI thread. Remove event listeners when their consumers are disposed, or use channels when a command needs ordered progress updates.

Scope native access

  • Map each plugin permission and scope to the window or webview that needs it. Inspect all capabilities that match a label, since their permissions combine. Keep filesystem and similar scopes limited to the files or directories the feature needs.
  • Application commands registered in invoke_handler are accessible to the app's windows and webviews by default. For commands that need capability enforcement, declare the commands in the build-time app manifest and grant their permissions to the intended windows. Test the allowed and denied paths in the configured app.
  • Keep remote origins out of native capabilities by default. For a refused call, check the command registration, invoking label, active capability, and plugin scope before changing permissions.

Verify the shipped behavior

  • Exercise the command's success and rejection paths, then repeat the real UI action in a running Tauri app. For persisted preferences, change the value, confirm the native consumer uses it, and verify it after relaunch in a test profile.
  • If development works but the packaged build fails, verify the configured frontendDist, bundled assets and sidecars, and the target webview or OS dependency. Build using the project's Tauri command, then smoke-test the produced installer or application bundle on each affected target you can verify.
  • For updater changes, check the version, target entry, artifact URL, and signature for the exact bytes. Verify OS signing or notarization for the distribution channel separately. Exercise an update from a supported previous build in an authorized test environment and verify the launched version and retained state.

Example

The desktop app previews a page-size setting. Verify that the webview sends the expected key and that Rust returns a usable error for a value outside the supported range.

Use the worked command and IPC test to check a successful invocation, a rejected value, and a mismatched argument key through Tauri's command handler.

Limitations

  • This workflow covers Tauri v2 desktop apps. Consult target-specific guides for Android and iOS.
  • Mock-runtime tests verify command dispatch and serialization. Webview rendering, configured permissions, native integrations, and distribution behavior require their corresponding target checks.

Safety and Side Effects

Use a test profile for native state changes and preserve real app data. Inspect unfamiliar build hooks before running them. Builds can download dependencies and write artifacts. Obtain authorization for installations on a user machine, publishing signed packages, and changes to live updater endpoints. Keep signing keys out of source, logs, and IPC responses.