Upload plugin JavaScript package installation
Install the JavaScript guest bindings for the upload plugin using `npm install @tauri-apps/plugin-upload`, `yarn add @tauri-apps/plugin-upload`, `pnpm add @tauri-apps/plugin-upload`, `deno add npm:@tauri-apps/plugin-upload`, or `bun add @tauri-apps/plugin-upload`.
Websocket plugin setup - manual installation steps
For manual setup: (1) Run 'cargo add tauri-plugin-websocket' in the src-tauri folder to add the plugin dependency. (2) Modify src-tauri/src/lib.rs to call .plugin(tauri_plugin_websocket::init()) in the tauri::Builder chain. (3) Install the JavaScript bindings using 'npm install @tauri-apps/plugin-websocket', 'yarn add @tauri-apps/plugin-websocket', 'pnpm add @tauri-apps/plugin-websocket', 'deno add npm:@tauri-apps/plugin-websocket', or 'bun add @tauri-apps/plugin-websocket'.
Websocket plugin permissions model
By default, all potentially dangerous plugin commands and scopes are blocked. Permissions must be explicitly enabled in the capabilities configuration to use the websocket plugin.
Websocket plugin default capability configuration
To enable the websocket plugin, add the permission 'websocket:default' to the permissions array in your capabilities configuration file (e.g., src-tauri/capabilities/default.json).
Websocket plugin setup - automatic installation
To install the websocket plugin automatically, run one of the following commands in your project: 'npm run tauri add websocket', 'yarn run tauri add websocket', 'pnpm tauri add websocket', 'bun tauri add websocket', 'deno task tauri add websocket', or 'cargo tauri add websocket'.
Websocket plugin JavaScript API example
The following example shows how to use the websocket plugin in JavaScript: import WebSocket from '@tauri-apps/plugin-websocket'; const ws = await WebSocket.connect('ws://127.0.0.1:8080'); const removeListener = ws.addListener((msg) => { console.log('Received Message:', msg); }); await ws.send('Hello World!'); removeListener(); await ws.disconnect(); Alternatively, when using 'withGlobalTauri': true, access it via window.__TAURI__.websocket.
Updater check with custom options (Rust)
When checking for updates in Rust, you can define custom timeout, proxy, and headers using the updater builder:
```rust
use tauri_plugin_updater::UpdaterExt;
let update = app
.updater_builder()
.timeout(std::time::Duration::from_secs(30))
.proxy("<proxy-url>".parse().expect("invalid URL"))
.header("Authorization", "Bearer <token>")
.build()?
.check()
.await?;
```
Updater plugin installation
Install the Tauri updater plugin using the command `npm run tauri add updater` (npm), `yarn run tauri add updater` (yarn), `pnpm tauri add updater` (pnpm), `deno task tauri add updater` (deno), `bun tauri add updater` (bun), or `cargo tauri add updater` (cargo).
Updater plugin manual setup in Rust
To manually initialize the updater plugin in Rust, add the dependency with `cargo add tauri-plugin-updater --target 'cfg(any(target_os = "macos", windows, target_os = "linux"))'`, then modify `lib.rs` to include the plugin builder in the setup: `app.handle().plugin(tauri_plugin_updater::Builder::new().build());` (only for desktop platforms using `#[cfg(desktop)]`).
Updater plugin JavaScript bindings
Install the JavaScript Guest bindings for the updater plugin using `npm install @tauri-apps/plugin-updater` (npm), `yarn add @tauri-apps/plugin-updater` (yarn), `pnpm add @tauri-apps/plugin-updater` (pnpm), `deno add npm:@tauri-apps/plugin-updater` (deno), or `bun add @tauri-apps/plugin-updater` (bun).
Updater requires signature verification
Tauri's updater requires a signature to verify that the update is from a trusted source. This verification cannot be disabled.
Updater signing keys generation
Generate updater signing keys using the Tauri CLI command `tauri signer generate` with the `-w` flag to specify the output path, for example: `npm run tauri signer generate -- -w ~/.tauri/myapp.key` (npm), `yarn tauri signer generate -w ~/.tauri/myapp.key` (yarn), `pnpm tauri signer generate -w ~/.tauri/myapp.key` (pnpm), `deno task tauri signer generate -w ~/.tauri/myapp.key` (deno), `bunx tauri signer generate -w ~/.tauri/myapp.key` (bun), or `cargo tauri signer generate -w ~/.tauri/myapp.key` (cargo).
Updater private key environment variables
Before building update artifacts, set the private key in environment variables (not in .env files). On Mac/Linux use: `export TAURI_SIGNING_PRIVATE_KEY="Path or content of your private key"` and optionally `export TAURI_SIGNING_PRIVATE_KEY_PASSWORD=""`. On Windows PowerShell use: `$env:TAURI_SIGNING_PRIVATE_KEY="Path or content of your private key"` and optionally `$env:TAURI_SIGNING_PRIVATE_KEY_PASSWORD=""`.
Updater artifacts configuration values
The Tauri configuration key `createUpdaterArtifacts` controls update artifact generation. Set it to `true` for v2 format, or `"v1Compatible"` for v1-compatible format. This setting will be removed in v3, so users must migrate to `true` once all users are on v2.
Linux updater artifacts (v1 compatible format)
On Linux with v1 compatible format, Tauri creates in `target/release/bundle/appimage/`: `myapp.AppImage` (standard app bundle), `myapp.AppImage.tar.gz` (updater bundle), `myapp.AppImage.tar.gz.sig` (signature of update bundle).
macOS updater artifacts (v1 compatible format)
On macOS with v1 compatible format, Tauri creates in `target/release/bundle/macos/`: `myapp.app` (standard app bundle), `myapp.app.tar.gz` (updater bundle), `myapp.app.tar.gz.sig` (signature of update bundle).
Windows updater artifacts (v1 compatible format)
On Windows with v1 compatible format, Tauri creates in `target/release/bundle/msi/` and `target/release/bundle/nsis/`: `myapp-setup.exe` (standard app bundle), `myapp-setup.nsis.zip` (updater bundle), `myapp-setup.nsis.zip.sig` (signature), `myapp.msi` (standard app bundle), `myapp.msi.zip` (updater bundle), `myapp.msi.zip.sig` (signature).
Updater tauri.conf.json configuration keys
The updater configuration table has these keys: `createUpdaterArtifacts` (boolean or "v1Compatible", tells bundler to create updater artifacts), `pubkey` (required, public key string generated by CLI, cannot be a file path), `endpoints` (required, array of endpoint URL strings, TLS enforced in production), `dangerousInsecureTransportProtocol` (boolean, allows non-HTTPS endpoints when true, use with caution).
Updater endpoint dynamic variables
Updater URLs support three dynamic variables: `{{current_version}}` (version of app requesting update), `{{target}}` (OS name: linux, windows, or darwin), `{{arch}}` (machine architecture: x86_64, i686, aarch64, or armv7). Custom variables are not supported, but custom `{{target}}` can be defined.
Windows installMode configuration
Windows updater has an optional `installMode` configuration option with three values: `"passive"` (small progress bar window, no user interaction required, default and recommended), `"basicUi"` (basic UI requiring user interaction), `"quiet"` (no progress feedback, requires admin privileges or user-wide installation).
Static JSON updater server response format
Static JSON updater response has these keys: `version` (required, valid SemVer with or without leading v), `notes` (optional, update notes), `pub_date` (optional, RFC 3339 format), `platforms` (required, object with OS-ARCH format keys like linux-x86_64, windows-x86_64, darwin-x86_64), where each platform has `signature` (required, .sig file content) and `url` (required, update bundle URL). The value must be the actual signature content, not a path or URL.
Static JSON updater server platform format
Updater static JSON platform keys use OS-ARCH format where OS is one of `linux`, `darwin`, or `windows`, and ARCH is one of `x86_64`, `aarch64`, `i686`, or `armv7`. When using custom targets, the provided target string is matched against platform keys instead of default OS-ARCH.
Dynamic updater server response format
Dynamic updater server response with status 200 OK has these keys: `version` (required, valid SemVer with or without leading v), `url` (required, valid URL to update bundle), `signature` (required, .sig file content), `notes` (optional, update notes), `pub_date` (optional, RFC 3339 format). Server should respond with 204 No Content if no update is available.
Updater JavaScript API example
Example JavaScript code to check and install updates:
```js
import { check } from '@tauri-apps/plugin-updater';
import { relaunch } from '@tauri-apps/plugin-process';
const update = await check();
if (update) {
console.log(
`found update ${update.version} from ${update.date} with notes ${update.body}`
);
let downloaded = 0;
let contentLength = 0;
// alternatively we could also call update.download() and update.install() separately
await update.downloadAndInstall((event) => {
switch (event.event) {
case 'Started':
contentLength = event.data.contentLength;
console.log(`started downloading ${event.data.contentLength} bytes`);
break;
case 'Progress':
downloaded += event.data.chunkLength;
console.log(`downloaded ${downloaded} from ${contentLength}`);
break;
case 'Finished':
console.log('download finished');
break;
}
});
console.log('update installed');
await relaunch();
}
```
Updater Rust API example
Example Rust code to check and install updates:
```rust
use tauri_plugin_updater::UpdaterExt;
pub fn run() {
tauri::Builder::default()
.setup(|app| {
let handle = app.handle().clone();
tauri::async_runtime::spawn(async move {
update(handle).await.unwrap();
});
Ok(())
})
.run(tauri::generate_context!())
.unwrap();
}
async fn update(app: tauri::AppHandle) -> tauri_plugin_updater::Result<()> {
if let Some(update) = app.updater()?.check().await? {
let mut downloaded = 0;
// alternatively we could also call update.download() and update.install() separately
update
.download_and_install(
|chunk_length, content_length| {
downloaded += chunk_length;
println!("downloaded {downloaded} from {content_length:?}");
},
|| {
println!("download finished");
},
)
.await?;
println!("update installed");
app.restart();
}
Ok(())
}
```
Updater app restart behavior
Restarting the app immediately after installing an update is not required. You can choose how to handle the update by either waiting until the user manually restarts the app, or prompting them to select when to do so. On Windows, the application is automatically exited when the install step is executed due to a limitation of Windows installers.
Updater check with custom options (JavaScript)
When checking for updates in JavaScript, you can define custom request timeout, proxy, and headers:
```js
import { check } from '@tauri-apps/plugin-updater';
const update = await check({
proxy: '<proxy url>',
timeout: 30000 /* milliseconds */,
headers: {
Authorization: 'Bearer <token>',
},
});
```
Updater runtime endpoints configuration
You can set updater endpoints at runtime using the updater builder. When using `format!()` to interpolate the update URL, you need double escapes for the variables like `{{{{target}}}}`. Example: `let update_url = format!("https://{channel}.myserver.com/{{{{target}}}}-{{{{arch}}}}/{{{{current_version}}}}");`
Updater public key runtime configuration
The updater public key can be set at runtime for key rotation logic using either the plugin builder: `tauri_plugin_updater::Builder::new().pubkey("<your public key>").build()`, or the updater builder: `app.updater_builder().pubkey("<your public key>").build()?`
Updater custom target configuration
By default the updater uses `{{target}}` and `{{arch}}` variables. You can set a custom target for cases like Universal macOS binaries or multiple build flavors. In JavaScript: `await check({ target: 'macos-universal' });`. In Rust, use either the plugin builder: `tauri_plugin_updater::Builder::new().target("macos-universal").build()`, or updater builder: `app.updater_builder().target("macos-universal").build()?`. The default target-arch key can be retrieved using `tauri_plugin_updater::target()` which returns `Option<String>` that is `None` when the updater is not supported.
Updater downgrades allow configuration
By default Tauri checks if the update version is greater than the current app version. To allow downgrades, use the updater builder's `version_comparator` API:
```rust
use tauri_plugin_updater::UpdaterExt;
let update = app
.updater_builder()
.version_comparator(|current, update| {
// default comparison: `update.version > current`
update.version != current
})
.build()?
.check()
.await?;
```
Updater Windows before exit hook
Due to Windows installer limitations, Tauri automatically quits the application before installing updates on Windows. To perform an action before exit, use the `on_before_exit` function:
```rust
use tauri_plugin_updater::UpdaterExt;
let update = app
.updater_builder()
.on_before_exit(|| {
println!("app is about to exit on Windows!");
})
.build()?
.check()
.await?;
```
Updater plugin permissions
To enable updater plugin commands and scopes, add the permission `"updater:default"` to the capabilities configuration in `src-tauri/capabilities/default.json`.
Window State preventing flash on restore
To prevent the window from flashing when restoring state, set visible to false when creating the window. The plugin will show the window when it restores the state.
Window State default behavior
After adding the Window State plugin, all windows will automatically remember their state when the app closes and restore to their previous state on the next launch.
Window State saveWindowState JavaScript API
The saveWindowState() function in JavaScript manually saves the window state. It takes a StateFlags parameter. Usage: import { saveWindowState, StateFlags } from '@tauri-apps/plugin-window-state'; saveWindowState(StateFlags.ALL);
Window State restoreStateCurrent JavaScript API
The restoreStateCurrent() function in JavaScript manually restores a window's state from disk. It takes a StateFlags parameter. Usage: import { restoreStateCurrent, StateFlags } from '@tauri-apps/plugin-window-state'; restoreStateCurrent(StateFlags.ALL);
Window State global Tauri access
When using "withGlobalTauri": true, you can access the Window State plugin via window.__TAURI__.windowState, allowing access to saveWindowState and restoreStateCurrent without imports.
Window State plugin purpose
The Window State plugin saves window positions and sizes and restores them when the app is reopened.
Window State save_window_state Rust API
The save_window_state() method is exposed by the AppHandleExt trait in Rust. It takes a StateFlags parameter. Usage: use tauri_plugin_window_state::{AppHandleExt, StateFlags}; app.save_window_state(StateFlags::all());
Window State restore_state Rust API
The restore_state() method is exposed by the WindowExt trait in Rust and works on all Window types. It takes a StateFlags parameter. Usage: use tauri_plugin_window_state::{WindowExt, StateFlags}; window.restore_state(StateFlags::all());
Window State plugin permission requirement
By default, all potentially dangerous Window State plugin commands and scopes are blocked. You must add "window-state:default" to the permissions array in src-tauri/capabilities/default.json to enable access.
Window State plugin setup - automatic installation
The Window State plugin can be installed automatically using package managers with these commands: npm run tauri add window-state, yarn run tauri add window-state, pnpm tauri add window-state, deno task tauri add window-state, bun tauri add window-state, or cargo tauri add window-state.
Window State plugin setup - manual Cargo installation
To manually install the Window State plugin in the src-tauri folder, run: cargo add tauri-plugin-window-state --target 'cfg(any(target_os = "macos", windows, target_os = "linux"))'
Window State plugin initialization in Rust
To initialize the Window State plugin in lib.rs, add this code to the tauri::Builder setup: app.handle().plugin(tauri_plugin_window_state::Builder::default().build()); This should be wrapped in a #[cfg(desktop)] attribute.
Window State plugin JavaScript bindings installation
Install the JavaScript Guest bindings using one of these commands: npm install @tauri-apps/plugin-window-state, yarn add @tauri-apps/plugin-window-state, pnpm add @tauri-apps/plugin-window-state, deno add npm:@tauri-apps/plugin-window-state, or bun add @tauri-apps/plugin-window-state
Plugin development CLI reference location
CLI commands related to developing plugins are documented in the 'Develop a Tauri Plugin' guide, not in the general CLI reference.
Capabilities security boundaries protection
Capabilities can minimize impact of frontend compromise, prevent or reduce exposure of local system interfaces and data, and prevent or reduce possible privilege escalation from frontend to backend/system.
Example default capability for main window
A basic capability allows the main window to use core plugin default functionality and specific APIs. Example: identifier "main-capability", windows "main", permissions include "core:path:default", "core:event:default", "core:window:default", "core:app:default", "core:resources:default", "core:menu:default", "core:tray:default", and "core:window:allow-set-title".
Capabilities system purpose
Tauri provides a capabilities system to granularly enable and constrain the core exposure to the application frontend running in the system WebView. Capabilities define which permissions are granted or denied for which windows or webviews.
Capabilities affect multiple windows and webviews
Capabilities can affect multiple windows and webviews and these can be referenced in multiple capabilities. Windows and WebViews which are part of more than one capability effectively merge the security boundaries and permissions of all involved capabilities.
Remote API access configuration
By default the Tauri API is only accessible to bundled code shipped with the app. To allow remote sources access to certain Tauri Commands, define a `remote` object in the capability configuration with a `urls` array containing URL patterns (supporting wildcards like `https://*.tauri.app`).
Capability configuration structure
A capability file requires the following structure: `identifier` (string, required), `description` (string), `windows` (array of window labels or "*" for all), `permissions` (array of permission identifiers), `platforms` (optional array to target specific platforms: linux, macOS, windows, iOS, android), and `$schema` (pointing to the appropriate platform schema in gen/schemas directory).
Capability definition in tauri.conf.json
Capabilities can be defined in two ways in tauri.conf.json: (1) inline in the `app.security.capabilities` array with full capability objects, or (2) by referencing identifier strings of pre-defined capability files. Both methods can be mixed.
Core command exposure and AppManifest
By default, all commands registered using `tauri::Builder::invoke_handler` are allowed to be used by all windows and webviews. To restrict which commands are allowed, use `AppManifest::commands` in src-tauri/build.rs to specify an array of allowed command names.
Platform-specific capabilities
Capabilities can be platform-specific by defining a `platforms` array. By default a capability is applied to all targets, but you can select a subset of: linux, macOS, windows, iOS, and android.
Build pipelines use GitHub Actions with human review
The process of releasing source-code artifacts is highly automated in GitHub build pipelines using GitHub Actions, but mandates kickoff and review from real humans.
Release process includes security audit before publishing
The Tauri working group reviews code changes and tags PRs with scope. They internally audit all security relevant PRs before publishing minor and major releases.
Tauri ecosystem repositories hosted on GitHub
The Tauri organization ecosystem is hosted on GitHub and includes security features to make repositories more resilient against adversaries targeting source code and releases.
Core repositories require signed commits
Tauri core repositories require signed commits to reduce the risk of impersonation and to allow identification of attributed commits after detection of possible compromise.