Process
This plugin provides APIs to access the current process. To spawn child processes, see the shell plugin.
Setup
Install the plugin-process to get started.
Use your project’s package manager to add the dependency:
npm run tauri add process
yarn run tauri add process
pnpm tauri add process
bun tauri add process
cargo tauri add process
-
Run
cargo add tauri-plugin-process
to add the plugin to the project’s dependencies inCargo.toml
. -
Modify
lib.rs
to initialize the plugin:lib.rs #[cfg_attr(mobile, tauri::mobile_entry_point)]pub fn run() {tauri::Builder::default()// Initialize the plugin.plugin(tauri_plugin_process::init()).run(tauri::generate_context!()).expect("error while running tauri application");} -
If you’d like to utilize the plugin in JavaScript then install the npm package as well:
npm install @tauri-apps/plugin-processyarn add @tauri-apps/plugin-processpnpm add @tauri-apps/plugin-processbun add @tauri-apps/plugin-process
Usage
The process plugin is available in both JavaScript and Rust.
import { exit, relaunch } from '@tauri-apps/plugin-process';
// exits the app with the given status codeawait exit(0);
// restarts the appawait relaunch();
Note that app
is an instance of AppHandle
.
// exits the app with the given status codeapp.exit(0);
// restarts the appapp.restart();
© 2024 Tauri Contributors. CC-BY / MIT