Capabilities for Different Windows and Platforms
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
This guide will help you customize the capabilities of your Tauri app.
Content of this guide
Section titled “Content of this guide”- Create multiple windows in a Tauri app
- Use different capabilities for different windows
- Use platform-specific capabilities
Prerequisites
Section titled “Prerequisites”This exercise is meant to be read after completing Using Plugin Permissions.
-
Create Multiple Windows in a Tauri Application
Section titled “Create Multiple Windows in a Tauri Application”Here we create an app with two windows labelled
firstandsecond. There are multiple ways to create windows in your Tauri application.Create Windows with the Tauri Configuration File
Section titled “Create Windows with the Tauri Configuration File”In the Tauri configuration file, usually named
tauri.conf.json:"productName": "multiwindow",..."app": {"windows": [{"label": "first","title": "First","width": 800,"height": 600},{"label": "second","title": "Second","width": 800,"height": 600}],},...}Create Windows Programmatically
Section titled “Create Windows Programmatically”In the Rust code to create a Tauri app:
tauri::Builder::default().invoke_handler(tauri::generate_handler![greet]).setup(|app| {let webview_url = tauri::WebviewUrl::App("index.html".into());// First windowtauri::WebviewWindowBuilder::new(app, "first", webview_url.clone()).title("First").build()?;// Second windowtauri::WebviewWindowBuilder::new(app, "second", webview_url).title("Second").build()?;Ok(())}).run(context).expect("error while running tauri application"); -
Apply Different Capabilities to Different Windows
Section titled “Apply Different Capabilities to Different Windows”The windows of a Tauri app can use different features or plugins of the Tauri backend. For better security it is recommended to only give the necessary capabilities to each window. We simulate a scenario where the
firstwindows uses filesystem and dialog functionalities andsecondonly needs dialog functionalities.Separate capability files per category
Section titled “Separate capability files per category”It is recommended to separate the capability files per category of actions they enable.
JSON files in the
src-tauri/capabilitieswill be taken into account for the capability system. Here we separate capabilities related to the filesystem and dialog window intofilesystem.jsonanddialog.json.filetree of the Tauri project:
/src/src-tauri/capabilitiesfilesystem.jsondialog.jsontauri.conf.jsonpackage.jsonREADME.mdGive filesystem capabilities to the
Section titled “Give filesystem capabilities to the first window”firstwindowWe give the
firstwindow the capability to have read access to the content of the$HOMEdirectory.Use the
windowsfield in a capability file with one or multiple window labels.filesystem.json {"identifier": "fs-read-home","description": "Allow access file access to home directory","local": true,"windows": ["first"],"permissions": ["fs:allow-home-read",]}Give dialog capabilities to the
Section titled “Give dialog capabilities to the first and second window”firstandsecondwindowWe give to
firstandsecondwindows the capability to create a “Yes/No” dialogUse the
windowsfield in a capability file with one or multiple window labels.dialog.json {"identifier": "dialog","description": "Allow to open a dialog","local": true,"windows": ["first", "second"],"permissions": ["dialog:allow-ask"]} -
Make Capabilities Platform Dependent
Section titled “Make Capabilities Platform Dependent”We now want to customize the capabilities to be active only on certain platforms. We make our filesystem capabilities only active on
linuxandwindows.Use the
platformsfield in a capability file to make it platform-specific.filesystem.json {"identifier": "fs-read-home","description": "Allow access file access to home directory","local": true,"windows": ["first"],"permissions": ["fs:allow-home-read",],"platforms": ["linux", "windows"]}The currently available platforms are
linux,windows,macos,android, andios.
Conclusion and Resources
Section titled “Conclusion and Resources”We have learned how to create multiple windows in a Tauri app and give them specific capabilities. Furthermore these capabilities can also be targeted to certain platforms.
An example application that used window capabilities can be found in the api example of the Tauri Github repository.
The fields that can be used in a capability file are listed in the Capability reference.
© 2026 Tauri Contributors. CC-BY / MIT