Skip to content
Tauri

OS Information

Read information about the operating system using the OS Information plugin.

Setup

Install the OS Information plugin to get started.

Use your project’s package manager to add the dependency:

npm run tauri add os

Usage

With this plugin you can query multiple information from current operational system. See all available functions in the JavaScript API or Rust API references.

Example: OS Platform

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 currentPlatform = await platform();
console.log(currentPlatform);
// Prints "windows" to the console

Permissions

By default all plugin commands are blocked and cannot be accessed. You must define a list of permissions in your capabilities configuration.

See Permissions Overview for more information.

src-tauri/capabilities/main.json
{
"permissions": [
...,
"os:allow-arch",
"os:allow-hostname",
"os:allow-os-type"
]
}
PermissionDescription
os:allow-archEnables the arch command without any pre-configured scope.
os:deny-archDenies the arch command without any pre-configured scope.
os:allow-exe-extensionEnables the exe-extension command without any pre-configured scope.
os:deny-exe-extensionDenies the exe-extension command without any pre-configured scope.
os:allow-familyEnables the family command without any pre-configured scope.
os:deny-familyDenies the family command without any pre-configured scope.
os:allow-hostnameEnables the hostname command without any pre-configured scope.
os:deny-hostnameDenies the hostname command without any pre-configured scope.
os:allow-localeEnables the locale command without any pre-configured scope.
os:deny-localeDenies the locale command without any pre-configured scope.
os:allow-os-typeEnables the os-type command without any pre-configured scope.
os:deny-os-typeDenies the os-type command without any pre-configured scope.
os:allow-platformEnables the platform command without any pre-configured scope.
os:deny-platformDenies the platform command without any pre-configured scope.
os:allow-versionEnables the version command without any pre-configured scope.
os:deny-versionDenies the version command without any pre-configured scope.

© 2024 Tauri Contributors. CC-BY / MIT