Skip to content
Tauri

Capabilities for Different Windows and Platforms

This guide will help you customize the capabilities of your Tauri app.

Content of this guide

  • Create multiple windows in a Tauri app
  • Use different capabilities for different windows
  • Use platform-specific capabilities

Prerequisites

This exercise is meant to be read after completing Using Plugin Permissions.

Guide

  1. Here we create an app with two windows labelled first and second. There are multiple ways to create windows in your Tauri application.

    In the Tauri configuration file, usually named tauri.conf.json:

    Create Windows Programatically

    In the Rust code to create a Tauri app:

  2. 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 first windows uses filesystem and dialog functionalities and second only needs dialog functionalities.

    It is recommended to separate the capability files per category of actions they enable.

    Give filesystem capabilities to the first window

    We give the first window the capability to have read access to the content of the $HOME directory.

    Give dialog capabilities to the first and second window

    We give to first and second windows the capability to create a “Yes/No” dialog

  3. We now want to customize the capabilities to be active only on certain platforms. We make our filesystem capabilities only active on linux and windows.

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.


© 2024 Tauri Contributors. CC-BY / MIT