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
​
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
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
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
​
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
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
>