OS Information
Read information about the operating system using the OS Information plugin.
Install the OS Information plugin to get started.
- Use your project’s package manager to add the dependency:
npm run tauri add os
yarn run tauri add os
pnpm tauri add os
cargo tauri add os
- Modify
lib.rs
to initialize the plugin:
#[cfg_attr(mobile, tauri::mobile_entry_point)]pub fn run() { tauri::Builder::default() // Initialize the plugin .plugin(tauri_plugin_os::init()) .run(tauri::generate_context!()) .expect("error while running tauri application");}
-
Run
cargo add tauri-plugin-os
to add the plugin to the project’s dependencies inCargo.toml
. -
Modify
lib.rs
to initialize the plugin:
#[cfg_attr(mobile, tauri::mobile_entry_point)]pub fn run() { tauri::Builder::default() // Initialize the plugin .plugin(tauri_plugin_os::init()) .run(tauri::generate_context!()) .expect("error while running tauri application");}
- If you’d like to use in JavaScript then install the npm package as well:
npm install @tauri-apps/plugin-os
yarn add @tauri-apps/plugin-os
pnpm add @tauri-apps/plugin-os
With this plugin you can query multiple information from current operational system. See all available functions in the JavaScript API or Rust API references.
platform
returns a string describing the specific operating system in use. The value is set at compile time. Possible values are linux
, macos
, ios
, freebsd
, dragonfly
, netbsd
, openbsd
, solaris
, android
, windows
.
import { platform } from '@tauri-apps/plugin-os';
const platform = await platform();console.log(platform);// Prints "windows" to the console
let platform = tauri_plugin_os::platform();println!("Platform: {}", platform);// Prints "windows" to the terminal
© 2023 Tauri Contributors. CC-BY / MIT