tauri-plugin-app-exit-api
v0.1.1
Published
A plugin for tauri@v2 to exit app.
Downloads
133
Maintainers
Readme
Tauri Plugin app-exit
A plugin for tauri@v2 to exit app.
Platform Supported
| Platform | Supported | | -------- | :-------: | | Linux | ✅ | | Windows | ✅ | | macOS | ✅ | | Android | ✅ | | iOS | ✅ |
This plugin is similar to tauri-plugin-process, with the addition of support for Android
and iOS
platforms.
Setup
Install the app-exit plugin to get started.
Run the following command in the
src-tauri
folder to add the plugin to the project’s dependencies inCargo.toml
:cargo add [email protected]
Modify
lib.rs
to initialize the plugin:#[cfg_attr(mobile, tauri::mobile_entry_point)] pub fn run() { tauri::Builder::default() + .plugin(tauri_plugin_app_exit::init()) .run(tauri::generate_context!()) .expect("error while running tauri application"); }
Install the JavaScript Guest bindings using your preferred JavaScript package manager:
pnpm add [email protected]
Modify
src-tauri/capabilities/default.json
to Allow the frontend to execute the exit_app command.{ "$schema": "../gen/schemas/desktop-schema.json", "identifier": "default", "description": "Capability for the main window", "windows": ["main"], "permissions": [ "core:default", + "app-exit:default" ] }
Usage
import { exitApp } from tauri-plugin-app-exit-api";
exitApp().catch(err => {
console.error(err)
})