$npx -y skills add luochang212/skill-zoo --skill tauri-updaterUse when adding software auto-update to a Tauri 2 desktop app, or when users ask about tauri-plugin-updater integration, app update checking, distinguishing installer vs portable builds for updates, or generating update manifests for GitHub Releases.
| 1 | # Tauri Updater |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | Add self-update to a Tauri 2 desktop app using `tauri-plugin-updater`. Covers macOS DMG, Windows NSIS (auto-install), and Windows portable (manual download link). Uses a GitHub Releases-hosted `latest.json` manifest with signed artifacts. |
| 6 | |
| 7 | ## When to Use |
| 8 | |
| 9 | - User asks to add "auto-update", "software update", "check for updates" to a Tauri app |
| 10 | - User asks about `tauri-plugin-updater` integration |
| 11 | - User wants to distinguish installer vs portable builds for update behavior |
| 12 | - User needs to generate update manifests for CI |
| 13 | |
| 14 | **Don't use for:** |
| 15 | - Tauri 1.x apps (different updater API) |
| 16 | - Mobile apps (different update mechanisms) |
| 17 | - Apps distributed only via app stores (use store update mechanisms) |
| 18 | |
| 19 | ## Architecture |
| 20 | |
| 21 | ### Installer vs Portable |
| 22 | |
| 23 | Tauri updater only works with installers (NSIS, MSI, DMG). Portable builds need a different path. |
| 24 | |
| 25 | | Build | Update method | Implementation | |
| 26 | |-------|-------------|----------------| |
| 27 | | macOS DMG | Auto-download + install | `tauri-plugin-updater` full flow | |
| 28 | | Windows NSIS | Auto-download + install | `tauri-plugin-updater` full flow | |
| 29 | | Windows Portable | Link to GitHub Releases | Button opens releases page | |
| 30 | |
| 31 | **Detecting portable at runtime**: Use a Cargo feature flag: |
| 32 | |
| 33 | ```toml |
| 34 | # Cargo.toml |
| 35 | [features] |
| 36 | portable = [] |
| 37 | ``` |
| 38 | |
| 39 | ```rust |
| 40 | // Rust command |
| 41 | #[tauri::command] |
| 42 | pub fn is_portable_build() -> bool { |
| 43 | cfg!(feature = "portable") |
| 44 | } |
| 45 | ``` |
| 46 | |
| 47 | Normal build: `cargo build --release` |
| 48 | Portable build: `cargo build --release --features portable` |
| 49 | |
| 50 | In `lib.rs`, conditionally register the updater plugin — skip it when the `portable` feature is active: |
| 51 | |
| 52 | ```rust |
| 53 | #[cfg(all(desktop, not(feature = "portable")))] |
| 54 | app.handle() |
| 55 | .plugin(tauri_plugin_updater::Builder::new().build()) |
| 56 | .expect("Failed to register updater plugin"); |
| 57 | ``` |
| 58 | |
| 59 | When `is_portable_build()` returns `true`, the frontend shows a GitHub Releases link instead of the auto-update flow. |
| 60 | |
| 61 | ## Implementation Steps |
| 62 | |
| 63 | ### 1. Generate Signing Key (one-time) |
| 64 | |
| 65 | ```bash |
| 66 | bun tauri signer generate -w ~/.tauri/<app-name>.key |
| 67 | ``` |
| 68 | |
| 69 | Hit enter twice for empty password. Produces: |
| 70 | - `~/.tauri/<app-name>.key` — private key → store as GitHub Secret `TAURI_SIGNING_PRIVATE_KEY` |
| 71 | - `~/.tauri/<app-name>.key.pub` — public key → paste into `tauri.conf.json` |
| 72 | |
| 73 | Empty password is fine — the key lives in encrypted GitHub Secrets. Adding a password means also managing `TAURI_SIGNING_PRIVATE_KEY_PASSWORD` in CI. |
| 74 | |
| 75 | ### 2. Rust Backend |
| 76 | |
| 77 | **`src-tauri/Cargo.toml`**: |
| 78 | |
| 79 | ```toml |
| 80 | [features] |
| 81 | portable = [] |
| 82 | |
| 83 | [dependencies] |
| 84 | tauri-plugin-updater = "2" |
| 85 | tauri-plugin-process = "2" |
| 86 | ``` |
| 87 | |
| 88 | **`src-tauri/src/lib.rs`**: |
| 89 | |
| 90 | ```rust |
| 91 | // Always register process plugin (needed for relaunch after update) |
| 92 | .plugin(tauri_plugin_process::init()) |
| 93 | .setup(|app| { |
| 94 | // Skip updater for portable builds |
| 95 | #[cfg(all(desktop, not(feature = "portable")))] |
| 96 | app.handle() |
| 97 | .plugin(tauri_plugin_updater::Builder::new().build()) |
| 98 | .expect("Failed to register updater plugin"); |
| 99 | |
| 100 | Ok(()) |
| 101 | }) |
| 102 | ``` |
| 103 | |
| 104 | Register `is_portable_build` as a Tauri command in the invoke handler. |
| 105 | |
| 106 | **Command file** (e.g. `commands/settings.rs`): |
| 107 | |
| 108 | ```rust |
| 109 | #[tauri::command] |
| 110 | pub fn is_portable_build() -> bool { |
| 111 | cfg!(feature = "portable") |
| 112 | } |
| 113 | ``` |
| 114 | |
| 115 | ### 3. Tauri Configuration |
| 116 | |
| 117 | **`src-tauri/tauri.conf.json`**: |
| 118 | |
| 119 | ```json |
| 120 | { |
| 121 | "bundle": { |
| 122 | "createUpdaterArtifacts": true |
| 123 | }, |
| 124 | "plugins": { |
| 125 | "updater": { |
| 126 | "pubkey": "<PUBLIC KEY FROM .pub FILE>", |
| 127 | "endpoints": [ |
| 128 | "https://github.com/<owner>/<repo>/releases/latest/download/latest.json" |
| 129 | ] |
| 130 | } |
| 131 | } |
| 132 | } |
| 133 | ``` |
| 134 | |
| 135 | The `releases/latest/download/` URL pattern uses GitHub's redirect to always serve the latest release's asset. |
| 136 | |
| 137 | Update CSP `connect-src` to allow GitHub release asset domains: |
| 138 | ``` |
| 139 | connect-src 'self' ipc: http://ipc.localhost https://api.github.com https://github.com https://objects.githubusercontent.com https://github-releases.githubusercontent.com |
| 140 | ``` |
| 141 | |
| 142 | **`src-tauri/capabilities/default.json`** — add permissions: |
| 143 | |
| 144 | ```json |
| 145 | { |
| 146 | "permissions": [ |
| 147 | "updater:default", |
| 148 | "process:default", |
| 149 | "process:allow-restart" |
| 150 | ] |
| 151 | } |
| 152 | ``` |
| 153 | |
| 154 | ### 4. Frontend |
| 155 | |
| 156 | **Install**: |
| 157 | |
| 158 | ```bash |
| 159 | bun add @tauri-apps/plugin-updater@^2 @tauri-apps/plugin-process@^2 |
| 160 | ``` |
| 161 | |
| 162 | **State machine**: |
| 163 | |
| 164 | ``` |
| 165 | idle → checking → up-to-date |
| 166 | → downloading → ready-to-restart |
| 167 | → available (download retry) → downloading → ready-to-restart |
| 168 | → error → idle (retry) |
| 169 | |
| 170 | Portable: always shows "GitHub Releases" link button |
| 171 | ``` |
| 172 | |
| 173 | | State | UI | Action | |
| 174 | |-------|----|--------| |
| 175 | | `idle` | "Check for Updates" button | `check()` | |
| 176 | | `checking` | Spinner, disabled button | Wait | |
| 177 | | `up-to-date` | "Up to date" | None | |
| 178 | | `downloading` | Version number + cumulative byte progress | |