Skip to main content

os

Provides operating system-related utility methods and properties.

This package is also accessible with window.__TAURI__.os when build.withGlobalTauri in tauri.conf.json is set to true.

The APIs must be added to tauri.allowlist.os in tauri.conf.json:

{
"tauri": {
"allowlist": {
"os": {
"all": true, // enable all Os APIs
}
}
}
}

It is recommended to allowlist only the APIs you use for optimal bundle size and security.

Type Aliases​

Arch​

Arch: "x86" | "x86\_64" | "arm" | "aarch64" | "mips" | "mips64" | "powerpc" | "powerpc64" | "riscv64" | "s390x" | "sparc64"

Defined in: os.ts:43

OsType​

OsType: "Linux" | "Darwin" | "Windows\_NT"

Defined in: os.ts:41

Platform​

Platform: "linux" | "darwin" | "ios" | "freebsd" | "dragonfly" | "netbsd" | "openbsd" | "solaris" | "android" | "win32"

Defined in: os.ts:29

Variables​

EOL​

Const EOL: "\n" | "\r\n"

The operating system-specific end-of-line marker.

  • \n on POSIX
  • \r\n on Windows

Since: 1.0.0

Defined in: os.ts:63

Functions​

arch​

arch(): Promise<Arch>

Returns the operating system CPU architecture for which the tauri app was compiled. Possible values are 'x86', 'x86_64', 'arm', 'aarch64', 'mips', 'mips64', 'powerpc', 'powerpc64', 'riscv64', 's390x', 'sparc64'.

Example

import { arch } from '@tauri-apps/api/os';
const archName = await arch();

Since: 1.0.0

Returns: Promise<Arch>

platform​

platform(): Promise<Platform>

Returns a string identifying the operating system platform. The value is set at compile time. Possible values are 'linux', 'darwin', 'ios', 'freebsd', 'dragonfly', 'netbsd', 'openbsd', 'solaris', 'android', 'win32'

Example

import { platform } from '@tauri-apps/api/os';
const platformName = await platform();

Since: 1.0.0

Returns: Promise<Platform>

tempdir​

tempdir(): Promise<string>

Returns the operating system's default directory for temporary files as a string.

Example

import { tempdir } from '@tauri-apps/api/os';
const tempdirPath = await tempdir();

Since: 1.0.0

Returns: Promise<string>

type​

type(): Promise<OsType>

Returns 'Linux' on Linux, 'Darwin' on macOS, and 'Windows_NT' on Windows.

Example

import { type } from '@tauri-apps/api/os';
const osType = await type();

Since: 1.0.0

Returns: Promise<OsType>

version​

version(): Promise<string>

Returns a string identifying the kernel version.

Example

import { version } from '@tauri-apps/api/os';
const osVersion = await version();

Since: 1.0.0

Returns: Promise<string>