app
Ce contenu n’est pas encore disponible dans votre langue.
Application metadata and lifecycle APIs: version and identifier, theme and dock visibility, data stores and exiting the app.
This package is also accessible with window.__TAURI__.app when app.withGlobalTauri in tauri.conf.json is set to true.
Remarks
Section titled “Remarks”Only the read-only commands are enabled by core:app:default
(allow-version, allow-name, allow-tauri-version, allow-identifier,
allow-bundle-type, allow-supports-multiple-windows, allow-register-listener
and allow-remove-listener). Every other function in this module documents the
permission it needs, which you must add to a capability yourself.
Enumerations
Section titled “Enumerations”BundleType
Section titled “BundleType”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/app.ts#L57
Bundle type of the current application.
2.7.0
Enumeration Members
Section titled “Enumeration Members”App: "app";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/app.ts#L69
macOS app bundle
AppImage
Section titled “AppImage”AppImage: "appimage";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/app.ts#L67
Linux AppImage
Deb: "deb";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/app.ts#L63
Linux Debian package
Msi: "msi";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/app.ts#L61
Windows MSI
Nsis: "nsis";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/app.ts#L59
Windows NSIS
Rpm: "rpm";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/app.ts#L65
Linux RPM
Type Aliases
Section titled “Type Aliases”DataStoreIdentifier
Section titled “DataStoreIdentifier”type DataStoreIdentifier = [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number];Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/app.ts#L31
Identifier type used for data stores on macOS and iOS.
Represents a 128-bit identifier, commonly expressed as a 16-byte UUID.
2.4.0
OnBackButtonPressPayload
Section titled “OnBackButtonPressPayload”type OnBackButtonPressPayload = object;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/app.ts#L294
Payload for the onBackButtonPress event.
2.9.0
Properties
Section titled “Properties”| Property | Type | Description | Defined in |
|---|---|---|---|
canGoBack |
boolean |
Whether the webview canGoBack property is true. | Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/app.ts#L296 |
Functions
Section titled “Functions”defaultWindowIcon()
Section titled “defaultWindowIcon()”function defaultWindowIcon(): Promise<Image | null>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/app.ts#L225
Gets the default window icon.
Returns
Section titled “Returns”Example
Section titled “Example”import { defaultWindowIcon } from '@tauri-apps/api/app';const icon = await defaultWindowIcon();Remarks
Section titled “Remarks”Requires the core:app:allow-default-window-icon permission (not
included in core:app:default).
2.0.0
exit()
Section titled “exit()”function exit(code?): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/app.ts#L400
Exits the app with the given exit code.
This is the same as the exit function of the @tauri-apps/plugin-process plugin,
but does not require a plugin to be installed.
Platform-specific
- Android: The activity is finished instead of the process being killed,
so the app closes with the system transition;
codeis ignored.
Parameters
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
code |
number |
0 |
The exit code to use. Defaults to 0. |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { exit } from '@tauri-apps/api/app';await exit(1);Remarks
Section titled “Remarks”Requires the core:app:allow-exit permission (not included in
core:app:default).
2.12.0
fetchDataStoreIdentifiers()
Section titled “fetchDataStoreIdentifiers()”function fetchDataStoreIdentifiers(): Promise<DataStoreIdentifier[]>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/app.ts#L182
Fetches the data store identifiers on macOS and iOS.
See https://developer.apple.com/documentation/webkit/wkwebsitedatastore for more information.
Returns
Section titled “Returns”Promise<DataStoreIdentifier[]>
Example
Section titled “Example”import { fetchDataStoreIdentifiers } from '@tauri-apps/api/app';const ids = await fetchDataStoreIdentifiers();Remarks
Section titled “Remarks”Requires the core:app:allow-fetch-data-store-identifiers permission
(not included in core:app:default).
2.4.0
getBundleType()
Section titled “getBundleType()”function getBundleType(): Promise<BundleType>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/app.ts#L285
Gets the application bundle type.
Returns
Section titled “Returns”Example
Section titled “Example”import { getBundleType } from '@tauri-apps/api/app';const type = await getBundleType();2.5.0
getIdentifier()
Section titled “getIdentifier()”function getIdentifier(): Promise<string>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/app.ts#L127
Gets the application identifier.
Returns
Section titled “Returns”Promise<string>
The application identifier as configured in tauri.conf.json.
Example
Section titled “Example”import { getIdentifier } from '@tauri-apps/api/app';const identifier = await getIdentifier();2.4.0
getName()
Section titled “getName()”function getName(): Promise<string>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/app.ts#L96
Gets the application name.
Returns
Section titled “Returns”Promise<string>
Example
Section titled “Example”import { getName } from '@tauri-apps/api/app';const appName = await getName();1.0.0
getTauriVersion()
Section titled “getTauriVersion()”function getTauriVersion(): Promise<string>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/app.ts#L111
Gets the Tauri framework version used by this application.
Returns
Section titled “Returns”Promise<string>
Example
Section titled “Example”import { getTauriVersion } from '@tauri-apps/api/app';const tauriVersion = await getTauriVersion();1.0.0
getVersion()
Section titled “getVersion()”function getVersion(): Promise<string>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/app.ts#L82
Gets the application version.
Returns
Section titled “Returns”Promise<string>
Example
Section titled “Example”import { getVersion } from '@tauri-apps/api/app';const appVersion = await getVersion();1.0.0
hide()
Section titled “hide()”function hide(): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/app.ts#L162
Hides the application on macOS.
Returns
Section titled “Returns”Promise<void>
Example
Section titled “Example”import { hide } from '@tauri-apps/api/app';await hide();Remarks
Section titled “Remarks”Requires the core:app:allow-app-hide permission (not included in core:app:default).
1.2.0
onBackButtonPress()
Section titled “onBackButtonPress()”function onBackButtonPress(handler): Promise<PluginListener>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/app.ts#L333
Listens to the Android hardware/gesture back button.
Registering a handler takes over the default behavior, so the app no longer
navigates back or closes on its own: decide what to do inside the handler,
using payload.canGoBack to know whether the webview has history to go back to.
Platform-specific
- Android: Supported.
- Windows / Linux / macOS / iOS: Unsupported, the handler is never called.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
handler |
(payload) => void |
Called on every back button press. |
Returns
Section titled “Returns”A listener handle, call unregister() on it to restore the default behavior.
Example
Section titled “Example”import { onBackButtonPress } from '@tauri-apps/api/app';import { exit } from '@tauri-apps/api/app';
const listener = await onBackButtonPress(({ canGoBack }) => { if (canGoBack) { window.history.back(); } else { void exit(0); }});
// stop handling the back buttonawait listener.unregister();2.9.0
removeDataStore()
Section titled “removeDataStore()”function removeDataStore(uuid): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/app.ts#L206
Removes the data store with the given identifier.
Note that any webview using this data store should be closed before running this API.
See https://developer.apple.com/documentation/webkit/wkwebsitedatastore for more information.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
uuid |
DataStoreIdentifier |
Returns
Section titled “Returns”Promise<void>
Example
Section titled “Example”import { fetchDataStoreIdentifiers, removeDataStore } from '@tauri-apps/api/app';for (const id of (await fetchDataStoreIdentifiers())) { await removeDataStore(id);}Remarks
Section titled “Remarks”Requires the core:app:allow-remove-data-store permission (not included
in core:app:default).
2.4.0
setDockVisibility()
Section titled “setDockVisibility()”function setDockVisibility(visible): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/app.ts#L270
Sets the dock visibility for the application on macOS.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
visible |
boolean |
Whether the dock should be visible or not. |
Returns
Section titled “Returns”Promise<void>
Example
Section titled “Example”import { setDockVisibility } from '@tauri-apps/api/app';await setDockVisibility(false);Remarks
Section titled “Remarks”Requires the core:app:allow-set-dock-visibility permission (not
included in core:app:default).
2.5.0
setTheme()
Section titled “setTheme()”function setTheme(theme?): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/app.ts#L250
Sets the application’s theme. Pass in null or undefined to follow
the system theme.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
theme? |
Theme | null |
Returns
Section titled “Returns”Promise<void>
Example
Section titled “Example”import { setTheme } from '@tauri-apps/api/app';await setTheme('dark');Platform-specific
- iOS / Android: Unsupported.
Remarks
Section titled “Remarks”Requires the core:app:allow-set-app-theme permission (not included in
core:app:default).
2.0.0
show()
Section titled “show()”function show(): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/app.ts#L145
Shows the application on macOS. This function does not automatically focus any specific app window.
Returns
Section titled “Returns”Promise<void>
Example
Section titled “Example”import { show } from '@tauri-apps/api/app';await show();Remarks
Section titled “Remarks”Requires the core:app:allow-app-show permission (not included in core:app:default).
1.2.0
supportsMultipleWindows()
Section titled “supportsMultipleWindows()”function supportsMultipleWindows(): Promise<boolean>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/app.ts#L371
Whether the current platform can show more than one window at a time.
Use it to hide or disable multi-window features on platforms where creating a second window is not possible.
Platform-specific
- Windows / Linux / macOS: Always
true. - Android:
trueon API level 32 (Android 12L) and above. - iOS: Reflects
UIApplication.supportsMultipleScenes, so it istrueon iPadOS andfalseon iPhone.
See the mobile multiwindow guide for how windows behave on mobile.
Returns
Section titled “Returns”Promise<boolean>
Example
Section titled “Example”import { supportsMultipleWindows } from '@tauri-apps/api/app';import { WebviewWindow } from '@tauri-apps/api/webviewWindow';
if (await supportsMultipleWindows()) { new WebviewWindow('settings', { url: '/settings' });}2.11.0
© 2026 Tauri Contributors. CC-BY / MIT