Reference: reference documentation for the JavaScript API, configuration schema, command line interface, and the permission system (ACL) # Capability A grouping and boundary mechanism developers can use to isolate access to the IPC layer. It controls application windows’ and webviews’ fine grained access to the Tauri core, application, or plugin commands. If a webview or its window is not matching any capability then it has no access to the IPC layer at all. This can be done to create groups of windows, based on their required system access, which can reduce impact of frontend vulnerabilities in less privileged windows. Windows can be added to a capability by exact name (e.g. `main-window`) or glob patterns like `*` or `admin-*`. A Window can have none, one, or multiple associated capabilities. ### Example ```json { "identifier": "main-user-files-write", "description": "This capability allows the `main` window on macOS and Windows access to `filesystem` write related commands and `dialog` commands to enable programmatic access to files selected by the user.", "windows": [ "main" ], "permissions": [ "core:default", "dialog:open", { "identifier": "fs:allow-write-text-file", "allow": [{ "path": "$HOME/test.txt" }] }, ], "platforms": ["macOS","windows"] } ``` **Object Properties**: * description * identifier (required) * local * permissions (required) * platforms * remote * webviews * windows ### description `string` Description of what the capability is intended to allow on associated windows. It should contain a description of what the grouped permissions should allow. #### Example This capability allows the `main` window access to `filesystem` write related commands and `dialog` commands to enable programmatic access to files selected by the user. ### identifier `string` Identifier of the capability. #### Example `main-user-files-write` ### local `boolean` Whether this capability is enabled for local app URLs or not. Defaults to `true`. **Default**: `true` ### permissions [`PermissionEntry`](#permissionentry)\[] each item must be unique List of permissions attached to this capability. Must include the plugin name as prefix in the form of `${plugin-name}:${permission-name}`. For commands directly implemented in the application itself only `${permission-name}` is required. #### Example ```json [ "core:default", "shell:allow-open", "dialog:open", { "identifier": "fs:allow-write-text-file", "allow": [{ "path": "$HOME/test.txt" }] } ] ``` ### platforms [`Target`](#target)\[] | `null` Limit which target platforms this capability applies to. By default all platforms are targeted. #### Example `["macOS","windows"]` ### remote [`CapabilityRemote`](#capabilityremote) | `null` Configure remote URLs that can use the capability permissions. This setting is optional and defaults to not being set, as our default use case is that the content is served from our local application. Caution Make sure you understand the security implications of providing remote sources with local system access. #### Example ```json { "urls": ["https://*.mydomain.dev"] } ``` ### webviews `string`\[] List of webviews that are affected by this capability. Can be a glob pattern. The capability will be enabled on all the webviews whose label matches any of the patterns in this list, regardless of whether the webview’s window label matches a pattern in \[`Self::windows`]. #### Example `["sub-webview-one", "sub-webview-two"]` ### windows `string`\[] List of windows that are affected by this capability. Can be a glob pattern. If a window label matches any of the patterns in this list, the capability will be enabled on all the webviews of that window, regardless of the value of \[`Self::webviews`]. On multiwebview windows, prefer specifying \[`Self::webviews`] and omitting \[`Self::windows`] for a fine grained access control. #### Example `["main"]` ## Definitions ### CapabilityRemote Configuration for remote URLs that are associated with the capability. **Object Properties**: * urls (required) ##### urls `string`\[] Remote domains this capability refers to using the [URLPattern standard](https://urlpattern.spec.whatwg.org/). ###### Examples * “https\://\*.mydomain.dev”: allows subdomains of mydomain.dev * “\*”: allows any subpath of mydomain.dev/api ### Identifier `string` ### Number **Any of the following**: * `integer` formatted as `int64` Represents an \[`i64`]. * `number` formatted as `double` Represents a \[`f64`]. A valid ACL number. ### PermissionEntry **Any of the following**: * [`Identifier`](#identifier) Reference a permission or permission set by identifier. * Reference a permission or permission set by identifier and extends its scope. **Object Properties**: - allow - deny - identifier (required) ##### allow [`Value`](#value)\[] | `null` Data that defines what is allowed by the scope. ##### deny [`Value`](#value)\[] | `null` Data that defines what is denied by the scope. This should be prioritized by validation logic. ##### identifier [`Identifier`](#identifier) Identifier of the permission or permission set. An entry for a permission value in a \[`Capability`] can be either a raw permission \[`Identifier`] or an object that references a permission and extends its scope. ### Target **One of the following**: * `"macOS"` MacOS. * `"windows"` Windows. * `"linux"` Linux. * `"android"` Android. * `"iOS"` iOS. Platform target. ### Value **Any of the following**: * `null` Represents a null JSON value. * `boolean` Represents a \[`bool`]. * [`Number`](#number) Represents a valid ACL \[`Number`]. * `string` Represents a \[`String`]. * [`Value`](#value)\[] Represents a list of other \[`Value`]s. * Represents a map of \[`String`] keys to \[`Value`]s. **Allows additional properties**: [`Value`](#value) All supported ACL values. # Core Permissions A list of all permissions that can be used with the core of the Tauri framework. If you are looking for permissions to specific Tauri plugins, please refer to the [Plugins section](/plugin/) of the documentation. ## Default Permissions The `core:default` permission in Tauri automatically adds: * `core:app:default` * `core:event:default` * `core:image:default` * `core:menu:default` * `core:path:default` * `core:resources:default` * `core:tray:default` * `core:webview:default` * `core:window:default` ## App ### Default Permission The default permission, `core:app:default`, includes the following: * `allow-version` * `allow-name` * `allow-tauri-version` * `allow-identifier` * `allow-bundle-type` * `allow-register-listener` * `allow-remove-listener` * `allow-supports-multiple-windows` ### Permission Table | Identifier | Description | | --------------------------------------------- | ------------------------------------------------------------------------------------ | | `core:app:allow-app-hide` | Enables the `app_hide` command without any pre-configured scope. | | `core:app:deny-app-hide` | Denies the `app_hide` command without any pre-configured scope. | | `core:app:allow-app-show` | Enables the `app_show` command without any pre-configured scope. | | `core:app:deny-app-show` | Denies the `app_show` command without any pre-configured scope. | | `core:app:allow-bundle-type` | Enables the `bundle_type` command without any pre-configured scope. | | `core:app:deny-bundle-type` | Denies the `bundle_type` command without any pre-configured scope. | | `core:app:allow-default-window-icon` | Enables the `default_window_icon` command without any pre-configured scope. | | `core:app:deny-default-window-icon` | Denies the `default_window_icon` command without any pre-configured scope. | | `core:app:allow-fetch-data-store-identifiers` | Enables the `fetch_data_store_identifiers` command without any pre-configured scope. | | `core:app:deny-fetch-data-store-identifiers` | Denies the `fetch_data_store_identifiers` command without any pre-configured scope. | | `core:app:allow-identifier` | Enables the `identifier` command without any pre-configured scope. | | `core:app:deny-identifier` | Denies the `identifier` command without any pre-configured scope. | | `core:app:allow-name` | Enables the `name` command without any pre-configured scope. | | `core:app:deny-name` | Denies the `name` command without any pre-configured scope. | | `core:app:allow-register-listener` | Enables the `register_listener` command without any pre-configured scope. | | `core:app:deny-register-listener` | Denies the `register_listener` command without any pre-configured scope. | | `core:app:allow-remove-data-store` | Enables the `remove_data_store` command without any pre-configured scope. | | `core:app:deny-remove-data-store` | Denies the `remove_data_store` command without any pre-configured scope. | | `core:app:allow-remove-listener` | Enables the `remove_listener` command without any pre-configured scope. | | `core:app:deny-remove-listener` | Denies the `remove_listener` command without any pre-configured scope. | | `core:app:allow-set-app-theme` | Enables the `set_app_theme` command without any pre-configured scope. | | `core:app:deny-set-app-theme` | Denies the `set_app_theme` command without any pre-configured scope. | | `core:app:allow-set-dock-visibility` | Enables the `set_dock_visibility` command without any pre-configured scope. | | `core:app:deny-set-dock-visibility` | Denies the `set_dock_visibility` command without any pre-configured scope. | | `core:app:allow-supports-multiple-windows` | Enables the `supports_multiple_windows` command without any pre-configured scope. | | `core:app:deny-supports-multiple-windows` | Denies the `supports_multiple_windows` command without any pre-configured scope. | | `core:app:allow-tauri-version` | Enables the `tauri_version` command without any pre-configured scope. | | `core:app:deny-tauri-version` | Denies the `tauri_version` command without any pre-configured scope. | | `core:app:allow-version` | Enables the `version` command without any pre-configured scope. | | `core:app:deny-version` | Denies the `version` command without any pre-configured scope. | ## Event ### Default Permission The default permission, `core:event:default`, includes the following: * `allow-listen` * `allow-unlisten` * `allow-emit` * `allow-emit-to` ### Permission Table | Identifier | Description | | --------------------------- | ---------------------------------------------------------------- | | `core:event:allow-emit` | Enables the `emit` command without any pre-configured scope. | | `core:event:deny-emit` | Denies the `emit` command without any pre-configured scope. | | `core:event:allow-emit-to` | Enables the `emit_to` command without any pre-configured scope. | | `core:event:deny-emit-to` | Denies the `emit_to` command without any pre-configured scope. | | `core:event:allow-listen` | Enables the `listen` command without any pre-configured scope. | | `core:event:deny-listen` | Denies the `listen` command without any pre-configured scope. | | `core:event:allow-unlisten` | Enables the `unlisten` command without any pre-configured scope. | | `core:event:deny-unlisten` | Denies the `unlisten` command without any pre-configured scope. | ## Image ### Default Permission The default permission, `core:image:default`, includes the following: * `allow-new` * `allow-from-bytes` * `allow-from-path` * `allow-rgba` * `allow-size` ### Permission Table | Identifier | Description | | ----------------------------- | ------------------------------------------------------------------ | | `core:image:allow-from-bytes` | Enables the `from_bytes` command without any pre-configured scope. | | `core:image:deny-from-bytes` | Denies the `from_bytes` command without any pre-configured scope. | | `core:image:allow-from-path` | Enables the `from_path` command without any pre-configured scope. | | `core:image:deny-from-path` | Denies the `from_path` command without any pre-configured scope. | | `core:image:allow-new` | Enables the `new` command without any pre-configured scope. | | `core:image:deny-new` | Denies the `new` command without any pre-configured scope. | | `core:image:allow-rgba` | Enables the `rgba` command without any pre-configured scope. | | `core:image:deny-rgba` | Denies the `rgba` command without any pre-configured scope. | | `core:image:allow-size` | Enables the `size` command without any pre-configured scope. | | `core:image:deny-size` | Denies the `size` command without any pre-configured scope. | ## Menu ### Default Permission The default permission, `core:menu:default`, includes the following: * `allow-new` * `allow-append` * `allow-prepend` * `allow-insert` * `allow-remove` * `allow-remove-at` * `allow-items` * `allow-get` * `allow-popup` * `allow-create-default` * `allow-set-as-app-menu` * `allow-set-as-window-menu` * `allow-text` * `allow-set-text` * `allow-is-enabled` * `allow-set-enabled` * `allow-set-accelerator` * `allow-set-as-windows-menu-for-nsapp` * `allow-set-as-help-menu-for-nsapp` * `allow-is-checked` * `allow-set-checked` * `allow-set-icon` ### Permission Table | Identifier | Description | | ----------------------------------------------- | ------------------------------------------------------------------------------------- | | `core:menu:allow-append` | Enables the `append` command without any pre-configured scope. | | `core:menu:deny-append` | Denies the `append` command without any pre-configured scope. | | `core:menu:allow-create-default` | Enables the `create_default` command without any pre-configured scope. | | `core:menu:deny-create-default` | Denies the `create_default` command without any pre-configured scope. | | `core:menu:allow-get` | Enables the `get` command without any pre-configured scope. | | `core:menu:deny-get` | Denies the `get` command without any pre-configured scope. | | `core:menu:allow-insert` | Enables the `insert` command without any pre-configured scope. | | `core:menu:deny-insert` | Denies the `insert` command without any pre-configured scope. | | `core:menu:allow-is-checked` | Enables the `is_checked` command without any pre-configured scope. | | `core:menu:deny-is-checked` | Denies the `is_checked` command without any pre-configured scope. | | `core:menu:allow-is-enabled` | Enables the `is_enabled` command without any pre-configured scope. | | `core:menu:deny-is-enabled` | Denies the `is_enabled` command without any pre-configured scope. | | `core:menu:allow-items` | Enables the `items` command without any pre-configured scope. | | `core:menu:deny-items` | Denies the `items` command without any pre-configured scope. | | `core:menu:allow-new` | Enables the `new` command without any pre-configured scope. | | `core:menu:deny-new` | Denies the `new` command without any pre-configured scope. | | `core:menu:allow-popup` | Enables the `popup` command without any pre-configured scope. | | `core:menu:deny-popup` | Denies the `popup` command without any pre-configured scope. | | `core:menu:allow-prepend` | Enables the `prepend` command without any pre-configured scope. | | `core:menu:deny-prepend` | Denies the `prepend` command without any pre-configured scope. | | `core:menu:allow-remove` | Enables the `remove` command without any pre-configured scope. | | `core:menu:deny-remove` | Denies the `remove` command without any pre-configured scope. | | `core:menu:allow-remove-at` | Enables the `remove_at` command without any pre-configured scope. | | `core:menu:deny-remove-at` | Denies the `remove_at` command without any pre-configured scope. | | `core:menu:allow-set-accelerator` | Enables the `set_accelerator` command without any pre-configured scope. | | `core:menu:deny-set-accelerator` | Denies the `set_accelerator` command without any pre-configured scope. | | `core:menu:allow-set-as-app-menu` | Enables the `set_as_app_menu` command without any pre-configured scope. | | `core:menu:deny-set-as-app-menu` | Denies the `set_as_app_menu` command without any pre-configured scope. | | `core:menu:allow-set-as-help-menu-for-nsapp` | Enables the `set_as_help_menu_for_nsapp` command without any pre-configured scope. | | `core:menu:deny-set-as-help-menu-for-nsapp` | Denies the `set_as_help_menu_for_nsapp` command without any pre-configured scope. | | `core:menu:allow-set-as-window-menu` | Enables the `set_as_window_menu` command without any pre-configured scope. | | `core:menu:deny-set-as-window-menu` | Denies the `set_as_window_menu` command without any pre-configured scope. | | `core:menu:allow-set-as-windows-menu-for-nsapp` | Enables the `set_as_windows_menu_for_nsapp` command without any pre-configured scope. | | `core:menu:deny-set-as-windows-menu-for-nsapp` | Denies the `set_as_windows_menu_for_nsapp` command without any pre-configured scope. | | `core:menu:allow-set-checked` | Enables the `set_checked` command without any pre-configured scope. | | `core:menu:deny-set-checked` | Denies the `set_checked` command without any pre-configured scope. | | `core:menu:allow-set-enabled` | Enables the `set_enabled` command without any pre-configured scope. | | `core:menu:deny-set-enabled` | Denies the `set_enabled` command without any pre-configured scope. | | `core:menu:allow-set-icon` | Enables the `set_icon` command without any pre-configured scope. | | `core:menu:deny-set-icon` | Denies the `set_icon` command without any pre-configured scope. | | `core:menu:allow-set-text` | Enables the `set_text` command without any pre-configured scope. | | `core:menu:deny-set-text` | Denies the `set_text` command without any pre-configured scope. | | `core:menu:allow-text` | Enables the `text` command without any pre-configured scope. | | `core:menu:deny-text` | Denies the `text` command without any pre-configured scope. | ## Path ### Default Permission The default permission, `core:path:default`, includes the following: * `allow-resolve-directory` * `allow-resolve` * `allow-normalize` * `allow-join` * `allow-dirname` * `allow-extname` * `allow-basename` * `allow-is-absolute` ### Permission Table | Identifier | Description | | ----------------------------------- | ------------------------------------------------------------------------- | | `core:path:allow-basename` | Enables the `basename` command without any pre-configured scope. | | `core:path:deny-basename` | Denies the `basename` command without any pre-configured scope. | | `core:path:allow-dirname` | Enables the `dirname` command without any pre-configured scope. | | `core:path:deny-dirname` | Denies the `dirname` command without any pre-configured scope. | | `core:path:allow-extname` | Enables the `extname` command without any pre-configured scope. | | `core:path:deny-extname` | Denies the `extname` command without any pre-configured scope. | | `core:path:allow-is-absolute` | Enables the `is_absolute` command without any pre-configured scope. | | `core:path:deny-is-absolute` | Denies the `is_absolute` command without any pre-configured scope. | | `core:path:allow-join` | Enables the `join` command without any pre-configured scope. | | `core:path:deny-join` | Denies the `join` command without any pre-configured scope. | | `core:path:allow-normalize` | Enables the `normalize` command without any pre-configured scope. | | `core:path:deny-normalize` | Denies the `normalize` command without any pre-configured scope. | | `core:path:allow-resolve` | Enables the `resolve` command without any pre-configured scope. | | `core:path:deny-resolve` | Denies the `resolve` command without any pre-configured scope. | | `core:path:allow-resolve-directory` | Enables the `resolve_directory` command without any pre-configured scope. | | `core:path:deny-resolve-directory` | Denies the `resolve_directory` command without any pre-configured scope. | ## Resources ### Default Permission The default permission, `core:resources:default`, includes the following: * `allow-close` ### Permission Table | Identifier | Description | | ---------------------------- | ------------------------------------------------------------- | | `core:resources:allow-close` | Enables the `close` command without any pre-configured scope. | | `core:resources:deny-close` | Denies the `close` command without any pre-configured scope. | ## Tray ### Default Permission The default permission, `core:tray:default`, includes the following: * `allow-new` * `allow-get-by-id` * `allow-remove-by-id` * `allow-set-icon` * `allow-set-menu` * `allow-set-tooltip` * `allow-set-title` * `allow-set-visible` * `allow-set-temp-dir-path` * `allow-set-icon-as-template` * `allow-set-icon-with-as-template` * `allow-set-show-menu-on-left-click` ### Permission Table | Identifier | Description | | --------------------------------------------- | ----------------------------------------------------------------------------------- | | `core:tray:allow-get-by-id` | Enables the `get_by_id` command without any pre-configured scope. | | `core:tray:deny-get-by-id` | Denies the `get_by_id` command without any pre-configured scope. | | `core:tray:allow-new` | Enables the `new` command without any pre-configured scope. | | `core:tray:deny-new` | Denies the `new` command without any pre-configured scope. | | `core:tray:allow-remove-by-id` | Enables the `remove_by_id` command without any pre-configured scope. | | `core:tray:deny-remove-by-id` | Denies the `remove_by_id` command without any pre-configured scope. | | `core:tray:allow-set-icon` | Enables the `set_icon` command without any pre-configured scope. | | `core:tray:deny-set-icon` | Denies the `set_icon` command without any pre-configured scope. | | `core:tray:allow-set-icon-as-template` | Enables the `set_icon_as_template` command without any pre-configured scope. | | `core:tray:deny-set-icon-as-template` | Denies the `set_icon_as_template` command without any pre-configured scope. | | `core:tray:allow-set-icon-with-as-template` | Enables the `set_icon_with_as_template` command without any pre-configured scope. | | `core:tray:deny-set-icon-with-as-template` | Denies the `set_icon_with_as_template` command without any pre-configured scope. | | `core:tray:allow-set-menu` | Enables the `set_menu` command without any pre-configured scope. | | `core:tray:deny-set-menu` | Denies the `set_menu` command without any pre-configured scope. | | `core:tray:allow-set-show-menu-on-left-click` | Enables the `set_show_menu_on_left_click` command without any pre-configured scope. | | `core:tray:deny-set-show-menu-on-left-click` | Denies the `set_show_menu_on_left_click` command without any pre-configured scope. | | `core:tray:allow-set-temp-dir-path` | Enables the `set_temp_dir_path` command without any pre-configured scope. | | `core:tray:deny-set-temp-dir-path` | Denies the `set_temp_dir_path` command without any pre-configured scope. | | `core:tray:allow-set-title` | Enables the `set_title` command without any pre-configured scope. | | `core:tray:deny-set-title` | Denies the `set_title` command without any pre-configured scope. | | `core:tray:allow-set-tooltip` | Enables the `set_tooltip` command without any pre-configured scope. | | `core:tray:deny-set-tooltip` | Denies the `set_tooltip` command without any pre-configured scope. | | `core:tray:allow-set-visible` | Enables the `set_visible` command without any pre-configured scope. | | `core:tray:deny-set-visible` | Denies the `set_visible` command without any pre-configured scope. | ## Webview ### Default Permission The default permission, `core:webview:default`, includes the following: * `allow-get-all-webviews` * `allow-webview-position` * `allow-webview-size` * `allow-internal-toggle-devtools` ### Permission Table | Identifier | Description | | ------------------------------------------------- | ------------------------------------------------------------------------------------ | | `core:webview:allow-clear-all-browsing-data` | Enables the `clear_all_browsing_data` command without any pre-configured scope. | | `core:webview:deny-clear-all-browsing-data` | Denies the `clear_all_browsing_data` command without any pre-configured scope. | | `core:webview:allow-create-webview` | Enables the `create_webview` command without any pre-configured scope. | | `core:webview:deny-create-webview` | Denies the `create_webview` command without any pre-configured scope. | | `core:webview:allow-create-webview-window` | Enables the `create_webview_window` command without any pre-configured scope. | | `core:webview:deny-create-webview-window` | Denies the `create_webview_window` command without any pre-configured scope. | | `core:webview:allow-get-all-webviews` | Enables the `get_all_webviews` command without any pre-configured scope. | | `core:webview:deny-get-all-webviews` | Denies the `get_all_webviews` command without any pre-configured scope. | | `core:webview:allow-internal-toggle-devtools` | Enables the `internal_toggle_devtools` command without any pre-configured scope. | | `core:webview:deny-internal-toggle-devtools` | Denies the `internal_toggle_devtools` command without any pre-configured scope. | | `core:webview:allow-print` | Enables the `print` command without any pre-configured scope. | | `core:webview:deny-print` | Denies the `print` command without any pre-configured scope. | | `core:webview:allow-reparent` | Enables the `reparent` command without any pre-configured scope. | | `core:webview:deny-reparent` | Denies the `reparent` command without any pre-configured scope. | | `core:webview:allow-set-webview-auto-resize` | Enables the `set_webview_auto_resize` command without any pre-configured scope. | | `core:webview:deny-set-webview-auto-resize` | Denies the `set_webview_auto_resize` command without any pre-configured scope. | | `core:webview:allow-set-webview-background-color` | Enables the `set_webview_background_color` command without any pre-configured scope. | | `core:webview:deny-set-webview-background-color` | Denies the `set_webview_background_color` command without any pre-configured scope. | | `core:webview:allow-set-webview-focus` | Enables the `set_webview_focus` command without any pre-configured scope. | | `core:webview:deny-set-webview-focus` | Denies the `set_webview_focus` command without any pre-configured scope. | | `core:webview:allow-set-webview-position` | Enables the `set_webview_position` command without any pre-configured scope. | | `core:webview:deny-set-webview-position` | Denies the `set_webview_position` command without any pre-configured scope. | | `core:webview:allow-set-webview-size` | Enables the `set_webview_size` command without any pre-configured scope. | | `core:webview:deny-set-webview-size` | Denies the `set_webview_size` command without any pre-configured scope. | | `core:webview:allow-set-webview-zoom` | Enables the `set_webview_zoom` command without any pre-configured scope. | | `core:webview:deny-set-webview-zoom` | Denies the `set_webview_zoom` command without any pre-configured scope. | | `core:webview:allow-webview-close` | Enables the `webview_close` command without any pre-configured scope. | | `core:webview:deny-webview-close` | Denies the `webview_close` command without any pre-configured scope. | | `core:webview:allow-webview-hide` | Enables the `webview_hide` command without any pre-configured scope. | | `core:webview:deny-webview-hide` | Denies the `webview_hide` command without any pre-configured scope. | | `core:webview:allow-webview-position` | Enables the `webview_position` command without any pre-configured scope. | | `core:webview:deny-webview-position` | Denies the `webview_position` command without any pre-configured scope. | | `core:webview:allow-webview-show` | Enables the `webview_show` command without any pre-configured scope. | | `core:webview:deny-webview-show` | Denies the `webview_show` command without any pre-configured scope. | | `core:webview:allow-webview-size` | Enables the `webview_size` command without any pre-configured scope. | | `core:webview:deny-webview-size` | Denies the `webview_size` command without any pre-configured scope. | ## Window ### Default Permission The default permission, `core:window:default`, includes the following: * `allow-get-all-windows` * `allow-scale-factor` * `allow-inner-position` * `allow-outer-position` * `allow-inner-size` * `allow-outer-size` * `allow-is-fullscreen` * `allow-is-minimized` * `allow-is-maximized` * `allow-is-focused` * `allow-is-decorated` * `allow-is-resizable` * `allow-is-maximizable` * `allow-is-minimizable` * `allow-is-closable` * `allow-is-visible` * `allow-is-enabled` * `allow-title` * `allow-current-monitor` * `allow-primary-monitor` * `allow-monitor-from-point` * `allow-available-monitors` * `allow-cursor-position` * `allow-theme` * `allow-is-always-on-top` * `allow-activity-name` * `allow-scene-identifier` * `allow-internal-toggle-maximize` ### Permission Table | Identifier | Description | | ------------------------------------------------- | ------------------------------------------------------------------------------------- | | `core:window:allow-activity-name` | Enables the `activity_name` command without any pre-configured scope. | | `core:window:deny-activity-name` | Denies the `activity_name` command without any pre-configured scope. | | `core:window:allow-available-monitors` | Enables the `available_monitors` command without any pre-configured scope. | | `core:window:deny-available-monitors` | Denies the `available_monitors` command without any pre-configured scope. | | `core:window:allow-center` | Enables the `center` command without any pre-configured scope. | | `core:window:deny-center` | Denies the `center` command without any pre-configured scope. | | `core:window:allow-close` | Enables the `close` command without any pre-configured scope. | | `core:window:deny-close` | Denies the `close` command without any pre-configured scope. | | `core:window:allow-create` | Enables the `create` command without any pre-configured scope. | | `core:window:deny-create` | Denies the `create` command without any pre-configured scope. | | `core:window:allow-current-monitor` | Enables the `current_monitor` command without any pre-configured scope. | | `core:window:deny-current-monitor` | Denies the `current_monitor` command without any pre-configured scope. | | `core:window:allow-cursor-position` | Enables the `cursor_position` command without any pre-configured scope. | | `core:window:deny-cursor-position` | Denies the `cursor_position` command without any pre-configured scope. | | `core:window:allow-destroy` | Enables the `destroy` command without any pre-configured scope. | | `core:window:deny-destroy` | Denies the `destroy` command without any pre-configured scope. | | `core:window:allow-get-all-windows` | Enables the `get_all_windows` command without any pre-configured scope. | | `core:window:deny-get-all-windows` | Denies the `get_all_windows` command without any pre-configured scope. | | `core:window:allow-hide` | Enables the `hide` command without any pre-configured scope. | | `core:window:deny-hide` | Denies the `hide` command without any pre-configured scope. | | `core:window:allow-inner-position` | Enables the `inner_position` command without any pre-configured scope. | | `core:window:deny-inner-position` | Denies the `inner_position` command without any pre-configured scope. | | `core:window:allow-inner-size` | Enables the `inner_size` command without any pre-configured scope. | | `core:window:deny-inner-size` | Denies the `inner_size` command without any pre-configured scope. | | `core:window:allow-internal-toggle-maximize` | Enables the `internal_toggle_maximize` command without any pre-configured scope. | | `core:window:deny-internal-toggle-maximize` | Denies the `internal_toggle_maximize` command without any pre-configured scope. | | `core:window:allow-is-always-on-top` | Enables the `is_always_on_top` command without any pre-configured scope. | | `core:window:deny-is-always-on-top` | Denies the `is_always_on_top` command without any pre-configured scope. | | `core:window:allow-is-closable` | Enables the `is_closable` command without any pre-configured scope. | | `core:window:deny-is-closable` | Denies the `is_closable` command without any pre-configured scope. | | `core:window:allow-is-decorated` | Enables the `is_decorated` command without any pre-configured scope. | | `core:window:deny-is-decorated` | Denies the `is_decorated` command without any pre-configured scope. | | `core:window:allow-is-enabled` | Enables the `is_enabled` command without any pre-configured scope. | | `core:window:deny-is-enabled` | Denies the `is_enabled` command without any pre-configured scope. | | `core:window:allow-is-focused` | Enables the `is_focused` command without any pre-configured scope. | | `core:window:deny-is-focused` | Denies the `is_focused` command without any pre-configured scope. | | `core:window:allow-is-fullscreen` | Enables the `is_fullscreen` command without any pre-configured scope. | | `core:window:deny-is-fullscreen` | Denies the `is_fullscreen` command without any pre-configured scope. | | `core:window:allow-is-maximizable` | Enables the `is_maximizable` command without any pre-configured scope. | | `core:window:deny-is-maximizable` | Denies the `is_maximizable` command without any pre-configured scope. | | `core:window:allow-is-maximized` | Enables the `is_maximized` command without any pre-configured scope. | | `core:window:deny-is-maximized` | Denies the `is_maximized` command without any pre-configured scope. | | `core:window:allow-is-minimizable` | Enables the `is_minimizable` command without any pre-configured scope. | | `core:window:deny-is-minimizable` | Denies the `is_minimizable` command without any pre-configured scope. | | `core:window:allow-is-minimized` | Enables the `is_minimized` command without any pre-configured scope. | | `core:window:deny-is-minimized` | Denies the `is_minimized` command without any pre-configured scope. | | `core:window:allow-is-resizable` | Enables the `is_resizable` command without any pre-configured scope. | | `core:window:deny-is-resizable` | Denies the `is_resizable` command without any pre-configured scope. | | `core:window:allow-is-visible` | Enables the `is_visible` command without any pre-configured scope. | | `core:window:deny-is-visible` | Denies the `is_visible` command without any pre-configured scope. | | `core:window:allow-maximize` | Enables the `maximize` command without any pre-configured scope. | | `core:window:deny-maximize` | Denies the `maximize` command without any pre-configured scope. | | `core:window:allow-minimize` | Enables the `minimize` command without any pre-configured scope. | | `core:window:deny-minimize` | Denies the `minimize` command without any pre-configured scope. | | `core:window:allow-monitor-from-point` | Enables the `monitor_from_point` command without any pre-configured scope. | | `core:window:deny-monitor-from-point` | Denies the `monitor_from_point` command without any pre-configured scope. | | `core:window:allow-outer-position` | Enables the `outer_position` command without any pre-configured scope. | | `core:window:deny-outer-position` | Denies the `outer_position` command without any pre-configured scope. | | `core:window:allow-outer-size` | Enables the `outer_size` command without any pre-configured scope. | | `core:window:deny-outer-size` | Denies the `outer_size` command without any pre-configured scope. | | `core:window:allow-primary-monitor` | Enables the `primary_monitor` command without any pre-configured scope. | | `core:window:deny-primary-monitor` | Denies the `primary_monitor` command without any pre-configured scope. | | `core:window:allow-request-user-attention` | Enables the `request_user_attention` command without any pre-configured scope. | | `core:window:deny-request-user-attention` | Denies the `request_user_attention` command without any pre-configured scope. | | `core:window:allow-scale-factor` | Enables the `scale_factor` command without any pre-configured scope. | | `core:window:deny-scale-factor` | Denies the `scale_factor` command without any pre-configured scope. | | `core:window:allow-scene-identifier` | Enables the `scene_identifier` command without any pre-configured scope. | | `core:window:deny-scene-identifier` | Denies the `scene_identifier` command without any pre-configured scope. | | `core:window:allow-set-always-on-bottom` | Enables the `set_always_on_bottom` command without any pre-configured scope. | | `core:window:deny-set-always-on-bottom` | Denies the `set_always_on_bottom` command without any pre-configured scope. | | `core:window:allow-set-always-on-top` | Enables the `set_always_on_top` command without any pre-configured scope. | | `core:window:deny-set-always-on-top` | Denies the `set_always_on_top` command without any pre-configured scope. | | `core:window:allow-set-background-color` | Enables the `set_background_color` command without any pre-configured scope. | | `core:window:deny-set-background-color` | Denies the `set_background_color` command without any pre-configured scope. | | `core:window:allow-set-badge-count` | Enables the `set_badge_count` command without any pre-configured scope. | | `core:window:deny-set-badge-count` | Denies the `set_badge_count` command without any pre-configured scope. | | `core:window:allow-set-badge-label` | Enables the `set_badge_label` command without any pre-configured scope. | | `core:window:deny-set-badge-label` | Denies the `set_badge_label` command without any pre-configured scope. | | `core:window:allow-set-closable` | Enables the `set_closable` command without any pre-configured scope. | | `core:window:deny-set-closable` | Denies the `set_closable` command without any pre-configured scope. | | `core:window:allow-set-content-protected` | Enables the `set_content_protected` command without any pre-configured scope. | | `core:window:deny-set-content-protected` | Denies the `set_content_protected` command without any pre-configured scope. | | `core:window:allow-set-cursor-grab` | Enables the `set_cursor_grab` command without any pre-configured scope. | | `core:window:deny-set-cursor-grab` | Denies the `set_cursor_grab` command without any pre-configured scope. | | `core:window:allow-set-cursor-icon` | Enables the `set_cursor_icon` command without any pre-configured scope. | | `core:window:deny-set-cursor-icon` | Denies the `set_cursor_icon` command without any pre-configured scope. | | `core:window:allow-set-cursor-position` | Enables the `set_cursor_position` command without any pre-configured scope. | | `core:window:deny-set-cursor-position` | Denies the `set_cursor_position` command without any pre-configured scope. | | `core:window:allow-set-cursor-visible` | Enables the `set_cursor_visible` command without any pre-configured scope. | | `core:window:deny-set-cursor-visible` | Denies the `set_cursor_visible` command without any pre-configured scope. | | `core:window:allow-set-decorations` | Enables the `set_decorations` command without any pre-configured scope. | | `core:window:deny-set-decorations` | Denies the `set_decorations` command without any pre-configured scope. | | `core:window:allow-set-effects` | Enables the `set_effects` command without any pre-configured scope. | | `core:window:deny-set-effects` | Denies the `set_effects` command without any pre-configured scope. | | `core:window:allow-set-enabled` | Enables the `set_enabled` command without any pre-configured scope. | | `core:window:deny-set-enabled` | Denies the `set_enabled` command without any pre-configured scope. | | `core:window:allow-set-focus` | Enables the `set_focus` command without any pre-configured scope. | | `core:window:deny-set-focus` | Denies the `set_focus` command without any pre-configured scope. | | `core:window:allow-set-focusable` | Enables the `set_focusable` command without any pre-configured scope. | | `core:window:deny-set-focusable` | Denies the `set_focusable` command without any pre-configured scope. | | `core:window:allow-set-fullscreen` | Enables the `set_fullscreen` command without any pre-configured scope. | | `core:window:deny-set-fullscreen` | Denies the `set_fullscreen` command without any pre-configured scope. | | `core:window:allow-set-icon` | Enables the `set_icon` command without any pre-configured scope. | | `core:window:deny-set-icon` | Denies the `set_icon` command without any pre-configured scope. | | `core:window:allow-set-ignore-cursor-events` | Enables the `set_ignore_cursor_events` command without any pre-configured scope. | | `core:window:deny-set-ignore-cursor-events` | Denies the `set_ignore_cursor_events` command without any pre-configured scope. | | `core:window:allow-set-max-size` | Enables the `set_max_size` command without any pre-configured scope. | | `core:window:deny-set-max-size` | Denies the `set_max_size` command without any pre-configured scope. | | `core:window:allow-set-maximizable` | Enables the `set_maximizable` command without any pre-configured scope. | | `core:window:deny-set-maximizable` | Denies the `set_maximizable` command without any pre-configured scope. | | `core:window:allow-set-min-size` | Enables the `set_min_size` command without any pre-configured scope. | | `core:window:deny-set-min-size` | Denies the `set_min_size` command without any pre-configured scope. | | `core:window:allow-set-minimizable` | Enables the `set_minimizable` command without any pre-configured scope. | | `core:window:deny-set-minimizable` | Denies the `set_minimizable` command without any pre-configured scope. | | `core:window:allow-set-overlay-icon` | Enables the `set_overlay_icon` command without any pre-configured scope. | | `core:window:deny-set-overlay-icon` | Denies the `set_overlay_icon` command without any pre-configured scope. | | `core:window:allow-set-position` | Enables the `set_position` command without any pre-configured scope. | | `core:window:deny-set-position` | Denies the `set_position` command without any pre-configured scope. | | `core:window:allow-set-progress-bar` | Enables the `set_progress_bar` command without any pre-configured scope. | | `core:window:deny-set-progress-bar` | Denies the `set_progress_bar` command without any pre-configured scope. | | `core:window:allow-set-resizable` | Enables the `set_resizable` command without any pre-configured scope. | | `core:window:deny-set-resizable` | Denies the `set_resizable` command without any pre-configured scope. | | `core:window:allow-set-shadow` | Enables the `set_shadow` command without any pre-configured scope. | | `core:window:deny-set-shadow` | Denies the `set_shadow` command without any pre-configured scope. | | `core:window:allow-set-simple-fullscreen` | Enables the `set_simple_fullscreen` command without any pre-configured scope. | | `core:window:deny-set-simple-fullscreen` | Denies the `set_simple_fullscreen` command without any pre-configured scope. | | `core:window:allow-set-size` | Enables the `set_size` command without any pre-configured scope. | | `core:window:deny-set-size` | Denies the `set_size` command without any pre-configured scope. | | `core:window:allow-set-size-constraints` | Enables the `set_size_constraints` command without any pre-configured scope. | | `core:window:deny-set-size-constraints` | Denies the `set_size_constraints` command without any pre-configured scope. | | `core:window:allow-set-skip-taskbar` | Enables the `set_skip_taskbar` command without any pre-configured scope. | | `core:window:deny-set-skip-taskbar` | Denies the `set_skip_taskbar` command without any pre-configured scope. | | `core:window:allow-set-theme` | Enables the `set_theme` command without any pre-configured scope. | | `core:window:deny-set-theme` | Denies the `set_theme` command without any pre-configured scope. | | `core:window:allow-set-title` | Enables the `set_title` command without any pre-configured scope. | | `core:window:deny-set-title` | Denies the `set_title` command without any pre-configured scope. | | `core:window:allow-set-title-bar-style` | Enables the `set_title_bar_style` command without any pre-configured scope. | | `core:window:deny-set-title-bar-style` | Denies the `set_title_bar_style` command without any pre-configured scope. | | `core:window:allow-set-visible-on-all-workspaces` | Enables the `set_visible_on_all_workspaces` command without any pre-configured scope. | | `core:window:deny-set-visible-on-all-workspaces` | Denies the `set_visible_on_all_workspaces` command without any pre-configured scope. | | `core:window:allow-show` | Enables the `show` command without any pre-configured scope. | | `core:window:deny-show` | Denies the `show` command without any pre-configured scope. | | `core:window:allow-start-dragging` | Enables the `start_dragging` command without any pre-configured scope. | | `core:window:deny-start-dragging` | Denies the `start_dragging` command without any pre-configured scope. | | `core:window:allow-start-resize-dragging` | Enables the `start_resize_dragging` command without any pre-configured scope. | | `core:window:deny-start-resize-dragging` | Denies the `start_resize_dragging` command without any pre-configured scope. | | `core:window:allow-theme` | Enables the `theme` command without any pre-configured scope. | | `core:window:deny-theme` | Denies the `theme` command without any pre-configured scope. | | `core:window:allow-title` | Enables the `title` command without any pre-configured scope. | | `core:window:deny-title` | Denies the `title` command without any pre-configured scope. | | `core:window:allow-toggle-maximize` | Enables the `toggle_maximize` command without any pre-configured scope. | | `core:window:deny-toggle-maximize` | Denies the `toggle_maximize` command without any pre-configured scope. | | `core:window:allow-unmaximize` | Enables the `unmaximize` command without any pre-configured scope. | | `core:window:deny-unmaximize` | Denies the `unmaximize` command without any pre-configured scope. | | `core:window:allow-unminimize` | Enables the `unminimize` command without any pre-configured scope. | | `core:window:deny-unminimize` | Denies the `unminimize` command without any pre-configured scope. | # Permission Descriptions of explicit privileges of commands. It can enable commands to be accessible in the frontend of the application. If the scope is defined it can be used to fine grain control the access of individual or multiple commands. **Object Properties**: * commands * description * identifier (required) * platforms * scope * version ### commands [`Commands`](#commands) Allowed or denied commands when using this permission. Default ```json { "allow": [], "deny": [] } ``` ### description `string` | `null` Human-readable description of what the permission does. Tauri internal convention is to use `<h4>` headings in markdown content for Tauri documentation generation purposes. ### identifier `string` A unique identifier for the permission. ### platforms [`Target`](#target)\[] | `null` Target platforms this permission applies. By default all platforms are affected by this permission. ### scope [`Scopes`](#scopes) Allowed or denied scoped when using this permission. ### version `integer` | `null` minimum of `1`, formatted as `uint64` The version of the permission. ## Definitions ### Commands Allowed and denied commands inside a permission. If two commands clash inside of `allow` and `deny`, it should be denied by default. **Object Properties**: * allow * deny ##### allow `string`\[] Allowed command. **Default**: `[]` ##### deny `string`\[] Denied command, which takes priority. **Default**: `[]` ### Number **Any of the following**: * `integer` formatted as `int64` Represents an \[`i64`]. * `number` formatted as `double` Represents a \[`f64`]. A valid ACL number. ### Scopes An argument for fine grained behavior control of Tauri commands. It can be of any serde serializable type and is used to allow or prevent certain actions inside a Tauri command. The configured scope is passed to the command and will be enforced by the command implementation. ##### Example ```json { "allow": [{ "path": "$HOME/**" }], "deny": [{ "path": "$HOME/secret.txt" }] } ``` **Object Properties**: * allow * deny ##### allow [`Value`](#value)\[] | `null` Data that defines what is allowed by the scope. ##### deny [`Value`](#value)\[] | `null` Data that defines what is denied by the scope. This should be prioritized by validation logic. ### Target **One of the following**: * `"macOS"` MacOS. * `"windows"` Windows. * `"linux"` Linux. * `"android"` Android. * `"iOS"` iOS. Platform target. ### Value **Any of the following**: * `null` Represents a null JSON value. * `boolean` Represents a \[`bool`]. * [`Number`](#number) Represents a valid ACL \[`Number`]. * `string` Represents a \[`String`]. * [`Value`](#value)\[] Represents a list of other \[`Value`]s. * Represents a map of \[`String`] keys to \[`Value`]s. **Allows additional properties**: [`Value`](#value) All supported ACL values. # Scope An argument for fine grained behavior control of Tauri commands. It can be of any serde serializable type and is used to allow or prevent certain actions inside a Tauri command. The configured scope is passed to the command and will be enforced by the command implementation. ### Example ```json { "allow": [{ "path": "$HOME/**" }], "deny": [{ "path": "$HOME/secret.txt" }] } ``` **Object Properties**: * allow * deny ### allow [`Value`](#value)\[] | `null` Data that defines what is allowed by the scope. ### deny [`Value`](#value)\[] | `null` Data that defines what is denied by the scope. This should be prioritized by validation logic. ## Definitions ### Number **Any of the following**: * `integer` formatted as `int64` Represents an \[`i64`]. * `number` formatted as `double` Represents a \[`f64`]. A valid ACL number. ### Value **Any of the following**: * `null` Represents a null JSON value. * `boolean` Represents a \[`bool`]. * [`Number`](#number) Represents a valid ACL \[`Number`]. * `string` Represents a \[`String`]. * [`Value`](#value)\[] Represents a list of other \[`Value`]s. * Represents a map of \[`String`] keys to \[`Value`]s. **Allows additional properties**: [`Value`](#value) All supported ACL values. # Command Line Interface The Tauri command line interface (CLI) is the way to interact with Tauri throughout the development lifecycle. You can add the Tauri CLI to your current project using your package manager of choice: * npm ```sh npm install --save-dev @tauri-apps/cli@latest ``` * yarn ```sh yarn add -D @tauri-apps/cli@latest ``` * pnpm ```sh pnpm add -D @tauri-apps/cli@latest ``` * deno ```sh deno add -D npm:@tauri-apps/cli@latest ``` * cargo ```sh cargo install tauri-cli --version "^2.0.0" --locked ``` ## List of Commands | Command | Description | | ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | | [`init`](#init) | Initialize a Tauri project in an existing directory | | [`dev`](#dev) | Run your app in development mode | | [`build`](#build) | Build your app in release mode and generate bundles and installers | | [`bundle`](#bundle) | Generate bundles and installers for your app (already built by `tauri build`) | | [`android`](#android) | Android commands | | [`android init`](#android-init) | Initialize Android target in the project | | [`android dev`](#android-dev) | Run your app in development mode on Android | | [`android build`](#android-build) | Build your app in release mode for Android and generate APKs and AABs | | [`android run`](#android-run) | Run your app in production mode on Android | | [`ios`](#ios) | iOS commands | | [`ios init`](#ios-init) | Initialize iOS target in the project | | [`ios dev`](#ios-dev) | Run your app in development mode on iOS | | [`ios build`](#ios-build) | Build your app in release mode for iOS and generate IPAs | | [`ios run`](#ios-run) | Run your app in production mode on iOS | | [`migrate`](#migrate) | Migrate from v1 to v2 | | [`info`](#info) | Show a concise list of information about the environment, Rust, Node.js and their versions as well as a few relevant project configurations | | [`add`](#add) | Add a tauri plugin to the project | | [`remove`](#remove) | Remove a tauri plugin from the project | | [`plugin`](#plugin) | Manage or create Tauri plugins | | [`plugin new`](#plugin-new) | Initializes a new Tauri plugin project | | [`plugin init`](#plugin-init) | Initialize a Tauri plugin project on an existing directory | | [`plugin android`](#plugin-android) | Manage the Android project for a Tauri plugin | | [`plugin ios`](#plugin-ios) | Manage the iOS project for a Tauri plugin | | [`plugin android init`](#plugin-android-init) | Initializes the Android project for an existing Tauri plugin | | [`plugin ios init`](#plugin-ios-init) | Initializes the iOS project for an existing Tauri plugin | | [`icon`](#icon) | Generate various icons for all major platforms | | [`signer`](#signer) | Generate signing keys for Tauri updater or sign files | | [`signer sign`](#signer-sign) | Sign a file | | [`signer generate`](#signer-generate) | Generate a new signing key to sign files | | [`completions`](#completions) | Generate Tauri CLI shell completions for Bash, Zsh, PowerShell or Fish | | [`permission`](#permission) | Manage or create permissions for your app or plugin | | [`permission new`](#permission-new) | Create a new permission file | | [`permission add`](#permission-add) | Add a permission to capabilities | | [`permission rm`](#permission-rm) | Remove a permission file, and its reference from any capability | | [`permission ls`](#permission-ls) | List permissions available to your application | | [`capability`](#capability) | Manage or create capabilities for your app | | [`capability new`](#capability-new) | Create a new permission file | | [`inspect`](#inspect) | Inspect values used by Tauri | | [`inspect wix-upgrade-code`](#inspect-wix-upgrade-code) | Print the default Upgrade Code used by MSI installer derived from productName | ### `init` * npm ```sh npm run tauri init ``` * yarn ```sh yarn tauri init ``` * pnpm ```sh pnpm tauri init ``` * deno ```sh deno task tauri init ``` * bun ```sh bun tauri init ``` * cargo ```sh cargo tauri init ``` ```plaintext Initialize a Tauri project in an existing directory Usage: tauri init [OPTIONS] Options: --ci Skip prompting for values [env: CI=true] -v, --verbose... Enables verbose logging -f, --force Force init to overwrite the src-tauri folder -l, --log Enables logging -d, --directory Set target directory for init [default: /opt/build/repo/packages/cli-generator] -t, --tauri-path Path of the Tauri project to use (relative to the cwd) -A, --app-name Name of your Tauri application -W, --window-title Window title of your Tauri application -D, --frontend-dist Web assets location, relative to /src-tauri -P, --dev-url Url of your dev server --before-dev-command A shell command to run before `tauri dev` kicks in --before-build-command A shell command to run before `tauri build` kicks in -h, --help Print help -V, --version Print version ``` ### `dev` * npm ```sh npm run tauri dev ``` * yarn ```sh yarn tauri dev ``` * pnpm ```sh pnpm tauri dev ``` * deno ```sh deno task tauri dev ``` * bun ```sh bun tauri dev ``` * cargo ```sh cargo tauri dev ``` ```plaintext Run your app in development mode with hot-reloading for the Rust code. It makes use of the `build.devUrl` property from your `tauri.conf.json` file. It also runs your `build.beforeDevCommand` which usually starts your frontend devServer. Usage: tauri dev [OPTIONS] [ARGS]... Arguments: [ARGS]... Command line arguments passed to the runner. Use `--` to explicitly mark the start of the arguments. Arguments after a second `--` are passed to the application e.g. `tauri dev -- [runnerArgs] -- [appArgs]` Options: -r, --runner Binary to use to run the application -v, --verbose... Enables verbose logging -t, --target Target triple to build against -f, --features [...] List of cargo features to activate -e, --exit-on-panic Exit on panic -c, --config JSON strings or paths to JSON, JSON5 or TOML files to merge with the default configuration file Configurations are merged in the order they are provided, which means a particular value overwrites previous values when a config key-value pair conflicts. Note that a platform-specific file is looked up and merged with the default file by default (tauri.macos.conf.json, tauri.linux.conf.json, tauri.windows.conf.json, tauri.android.conf.json and tauri.ios.conf.json) but you can use this for more specific use cases such as different build flavors. --release Run the code in release mode --no-dev-server-wait Skip waiting for the frontend dev server to start before building the tauri application [env: TAURI_CLI_NO_DEV_SERVER_WAIT=] --no-watch Disable the file watcher --additional-watch-folders Additional paths to watch for changes --no-dev-server Disable the built-in dev server for static files --port Specify port for the built-in dev server for static files. Defaults to 1430 [env: TAURI_CLI_PORT=] -h, --help Print help (see a summary with '-h') -V, --version Print version ``` ### `build` * npm ```sh npm run tauri build ``` * yarn ```sh yarn tauri build ``` * pnpm ```sh pnpm tauri build ``` * deno ```sh deno task tauri build ``` * bun ```sh bun tauri build ``` * cargo ```sh cargo tauri build ``` ```plaintext Build your app in release mode and generate bundles and installers. It makes use of the `build.frontendDist` property from your `tauri.conf.json` file. It also runs your `build.beforeBuildCommand` which usually builds your frontend into `build.frontendDist`. This will also run `build.beforeBundleCommand` before generating the bundles and installers of your app. Usage: tauri build [OPTIONS] [ARGS]... Arguments: [ARGS]... Command line arguments passed to the runner. Use `--` to explicitly mark the start of the arguments Options: -r, --runner Binary to use to build the application, defaults to `cargo` -v, --verbose... Enables verbose logging -d, --debug Builds with the debug flag -t, --target Target triple to build against. It must be one of the values outputted by `$rustc --print target-list` or `universal-apple-darwin` for an universal macOS application. Note that compiling an universal macOS application requires both `aarch64-apple-darwin` and `x86_64-apple-darwin` targets to be installed. -f, --features [...] Space or comma separated list of features to activate -b, --bundles [...] Space or comma separated list of bundles to package [possible values: deb, rpm, appimage] --no-bundle Skip the bundling step even if `bundle > active` is `true` in tauri config -c, --config JSON strings or paths to JSON, JSON5 or TOML files to merge with the default configuration file Configurations are merged in the order they are provided, which means a particular value overwrites previous values when a config key-value pair conflicts. Note that a platform-specific file is looked up and merged with the default file by default (tauri.macos.conf.json, tauri.linux.conf.json, tauri.windows.conf.json, tauri.android.conf.json and tauri.ios.conf.json) but you can use this for more specific use cases such as different build flavors. --ci Skip prompting for values [env: CI=true] --skip-stapling Whether to wait for notarization to finish and `staple` the ticket onto the app. Gatekeeper will look for stapled tickets to tell whether your app was notarized without reaching out to Apple's servers which is helpful in offline environments. Enabling this option will also result in `tauri build` not waiting for notarization to finish which is helpful for the very first time your app is notarized as this can take multiple hours. On subsequent runs, it's recommended to disable this setting again. --ignore-version-mismatches Do not error out if a version mismatch is detected on a Tauri package. Only use this when you are sure the mismatch is incorrectly detected as version mismatched Tauri packages can lead to unknown behavior. --no-sign Skip code signing when bundling the app -h, --help Print help (see a summary with '-h') -V, --version Print version ``` ### `bundle` * npm ```sh npm run tauri bundle ``` * yarn ```sh yarn tauri bundle ``` * pnpm ```sh pnpm tauri bundle ``` * deno ```sh deno task tauri bundle ``` * bun ```sh bun tauri bundle ``` * cargo ```sh cargo tauri bundle ``` ```plaintext Generate bundles and installers for your app (already built by `tauri build`). This run `build.beforeBundleCommand` before generating the bundles and installers of your app. Usage: tauri bundle [OPTIONS] Options: -d, --debug Builds with the debug flag -v, --verbose... Enables verbose logging -b, --bundles [...] Space or comma separated list of bundles to package [possible values: deb, rpm, appimage] -c, --config JSON strings or paths to JSON, JSON5 or TOML files to merge with the default configuration file Configurations are merged in the order they are provided, which means a particular value overwrites previous values when a config key-value pair conflicts. Note that a platform-specific file is looked up and merged with the default file by default (tauri.macos.conf.json, tauri.linux.conf.json, tauri.windows.conf.json, tauri.android.conf.json and tauri.ios.conf.json) but you can use this for more specific use cases such as different build flavors. -f, --features [...] Space or comma separated list of features, should be the same features passed to `tauri build` if any -t, --target Target triple to build against. It must be one of the values outputted by `$rustc --print target-list` or `universal-apple-darwin` for an universal macOS application. Note that compiling an universal macOS application requires both `aarch64-apple-darwin` and `x86_64-apple-darwin` targets to be installed. --ci Skip prompting for values [env: CI=true] --skip-stapling Whether to wait for notarization to finish and `staple` the ticket onto the app. Gatekeeper will look for stapled tickets to tell whether your app was notarized without reaching out to Apple's servers which is helpful in offline environments. Enabling this option will also result in `tauri build` not waiting for notarization to finish which is helpful for the very first time your app is notarized as this can take multiple hours. On subsequent runs, it's recommended to disable this setting again. --no-sign Skip code signing during the build or bundling process. Useful for local development and CI environments where signing certificates or environment variables are not available or not needed. -h, --help Print help (see a summary with '-h') -V, --version Print version ``` ### `android` * npm ```sh npm run tauri android ``` * yarn ```sh yarn tauri android ``` * pnpm ```sh pnpm tauri android ``` * deno ```sh deno task tauri android ``` * bun ```sh bun tauri android ``` * cargo ```sh cargo tauri android ``` ```plaintext Android commands Usage: tauri android [OPTIONS] Commands: init Initialize Android target in the project dev Run your app in development mode on Android build Build your app in release mode for Android and generate APKs and AABs run Run your app in production mode on Android help Print this message or the help of the given subcommand(s) Options: -v, --verbose... Enables verbose logging -h, --help Print help -V, --version Print version ``` #### `android init` * npm ```sh npm run tauri android init ``` * yarn ```sh yarn tauri android init ``` * pnpm ```sh pnpm tauri android init ``` * deno ```sh deno task tauri android init ``` * bun ```sh bun tauri android init ``` * cargo ```sh cargo tauri android init ``` ```plaintext Initialize Android target in the project Usage: tauri android init [OPTIONS] Options: --ci Skip prompting for values [env: CI=true] -v, --verbose... Enables verbose logging --skip-targets-install Skips installing rust toolchains via rustup -c, --config JSON strings or paths to JSON, JSON5 or TOML files to merge with the default configuration file Configurations are merged in the order they are provided, which means a particular value overwrites previous values when a config key-value pair conflicts. Note that a platform-specific file is looked up and merged with the default file by default (tauri.macos.conf.json, tauri.linux.conf.json, tauri.windows.conf.json, tauri.android.conf.json and tauri.ios.conf.json) but you can use this for more specific use cases such as different build flavors. -h, --help Print help (see a summary with '-h') -V, --version Print version ``` #### `android dev` * npm ```sh npm run tauri android dev ``` * yarn ```sh yarn tauri android dev ``` * pnpm ```sh pnpm tauri android dev ``` * deno ```sh deno task tauri android dev ``` * bun ```sh bun tauri android dev ``` * cargo ```sh cargo tauri android dev ``` ```plaintext Run your app in development mode on Android with hot-reloading for the Rust code. It makes use of the `build.devUrl` property from your `tauri.conf.json` file. It also runs your `build.beforeDevCommand` which usually starts your frontend devServer. Usage: tauri android dev [OPTIONS] [DEVICE] [-- ...] Arguments: [DEVICE] Runs on the given device name [ARGS]... Command line arguments passed to the runner. Use `--` to explicitly mark the start of the arguments. e.g. `tauri android dev -- [runnerArgs]` Options: -f, --features [...] List of cargo features to activate -v, --verbose... Enables verbose logging -e, --exit-on-panic Exit on panic -c, --config JSON strings or paths to JSON, JSON5 or TOML files to merge with the default configuration file Configurations are merged in the order they are provided, which means a particular value overwrites previous values when a config key-value pair conflicts. Note that a platform-specific file is looked up and merged with the default file by default (tauri.macos.conf.json, tauri.linux.conf.json, tauri.windows.conf.json, tauri.android.conf.json and tauri.ios.conf.json) but you can use this for more specific use cases such as different build flavors. --release Run the code in release mode --no-dev-server-wait Skip waiting for the frontend dev server to start before building the tauri application [env: TAURI_CLI_NO_DEV_SERVER_WAIT=] --no-watch Disable the file watcher --additional-watch-folders Additional paths to watch for changes -o, --open Open Android Studio instead of trying to run on a connected device --force-ip-prompt Force prompting for an IP to use to connect to the dev server on mobile --host [] Use the public network address for the development server. If an actual address it provided, it is used instead of prompting to pick one. On Windows we use the public network address by default. This option is particularly useful along the `--open` flag when you intend on running on a physical device. This replaces the devUrl configuration value to match the public network address host, it is your responsibility to set up your development server to listen on this address by using 0.0.0.0 as host for instance. When this is set or when running on an iOS device the CLI sets the `TAURI_DEV_HOST` environment variable so you can check this on your framework's configuration to expose the development server on the public network address. [default: ] --no-dev-server Disable the built-in dev server for static files --port Specify port for the built-in dev server for static files. Defaults to 1430 [env: TAURI_CLI_PORT=] --root-certificate-path Path to the certificate file used by your dev server. Required for mobile dev when using HTTPS [env: TAURI_DEV_ROOT_CERTIFICATE_PATH=] -h, --help Print help (see a summary with '-h') -V, --version Print version ``` #### `android build` * npm ```sh npm run tauri android build ``` * yarn ```sh yarn tauri android build ``` * pnpm ```sh pnpm tauri android build ``` * deno ```sh deno task tauri android build ``` * bun ```sh bun tauri android build ``` * cargo ```sh cargo tauri android build ``` ```plaintext Build your app in release mode for Android and generate APKs and AABs. It makes use of the `build.frontendDist` property from your `tauri.conf.json` file. It also runs your `build.beforeBuildCommand` which usually builds your frontend into `build.frontendDist`. Usage: tauri android build [OPTIONS] [-- ...] Arguments: [ARGS]... Command line arguments passed to the runner. Use `--` to explicitly mark the start of the arguments. e.g. `tauri android build -- [runnerArgs]` Options: -d, --debug Builds with the debug flag -v, --verbose... Enables verbose logging -t, --target [...] Which targets to build (all by default) [possible values: aarch64, armv7, i686, x86_64] -f, --features [...] List of cargo features to activate -c, --config JSON strings or paths to JSON, JSON5 or TOML files to merge with the default configuration file Configurations are merged in the order they are provided, which means a particular value overwrites previous values when a config key-value pair conflicts. Note that a platform-specific file is looked up and merged with the default file by default (tauri.macos.conf.json, tauri.linux.conf.json, tauri.windows.conf.json, tauri.android.conf.json and tauri.ios.conf.json) but you can use this for more specific use cases such as different build flavors. --split-per-abi Whether to split the APKs and AABs per ABIs --apk Build APKs --aab Build AABs -o, --open Open Android Studio --ci Skip prompting for values [env: CI=true] --ignore-version-mismatches Do not error out if a version mismatch is detected on a Tauri package. Only use this when you are sure the mismatch is incorrectly detected as version mismatched Tauri packages can lead to unknown behavior. -h, --help Print help (see a summary with '-h') -V, --version Print version ``` #### `android run` * npm ```sh npm run tauri android run ``` * yarn ```sh yarn tauri android run ``` * pnpm ```sh pnpm tauri android run ``` * deno ```sh deno task tauri android run ``` * bun ```sh bun tauri android run ``` * cargo ```sh cargo tauri android run ``` ```plaintext Run your app in production mode on Android. It makes use of the `build.frontendDist` property from your `tauri.conf.json` file. It also runs your `build.beforeBuildCommand` which usually builds your frontend into `build.frontendDist`. Usage: tauri android run [OPTIONS] [DEVICE] [-- ...] Arguments: [DEVICE] Runs on the given device name [ARGS]... Command line arguments passed to the runner. Use `--` to explicitly mark the start of the arguments. e.g. `tauri android build -- [runnerArgs]` Options: -r, --release Run the app in release mode -v, --verbose... Enables verbose logging -f, --features [...] List of cargo features to activate -c, --config JSON strings or paths to JSON, JSON5 or TOML files to merge with the default configuration file Configurations are merged in the order they are provided, which means a particular value overwrites previous values when a config key-value pair conflicts. Note that a platform-specific file is looked up and merged with the default file by default (tauri.macos.conf.json, tauri.linux.conf.json, tauri.windows.conf.json, tauri.android.conf.json and tauri.ios.conf.json) but you can use this for more specific use cases such as different build flavors. --no-watch Disable the file watcher --additional-watch-folders Additional paths to watch for changes -o, --open Open Android Studio --ignore-version-mismatches Do not error out if a version mismatch is detected on a Tauri package. Only use this when you are sure the mismatch is incorrectly detected as version mismatched Tauri packages can lead to unknown behavior. -h, --help Print help (see a summary with '-h') -V, --version Print version ``` ### `ios` *All iOS commands are only available on macOS hosts.* * npm ```sh npm run tauri ios ``` * yarn ```sh yarn tauri ios ``` * pnpm ```sh pnpm tauri ios ``` * deno ```sh deno task tauri ios ``` * bun ```sh bun tauri ios ``` * cargo ```sh cargo tauri ios ``` ```plaintext iOS commands Usage: tauri ios [OPTIONS] Commands: init Initialize iOS target in the project dev Run your app in development mode on iOS build Build your app in release mode for iOS and generate IPAs run Run your app in production mode on iOS help Print this message or the help of the given subcommand(s) Options: -v, --verbose... Enables verbose logging -h, --help Print help -V, --version Print version ``` #### `ios init` *All iOS commands are only available on macOS hosts.* * npm ```sh npm run tauri ios init ``` * yarn ```sh yarn tauri ios init ``` * pnpm ```sh pnpm tauri ios init ``` * deno ```sh deno task tauri ios init ``` * bun ```sh bun tauri ios init ``` * cargo ```sh cargo tauri ios init ``` ```plaintext Initialize iOS target in the project Usage: tauri ios init [OPTIONS] Options: --ci Skip prompting for values [env: CI=] -v, --verbose... Enables verbose logging -r, --reinstall-deps Reinstall dependencies --skip-targets-install Skips installing rust toolchains via rustup -c, --config JSON strings or paths to JSON, JSON5 or TOML files to merge with the default configuration file Configurations are merged in the order they are provided, which means a particular value overwrites previous values when a config key-value pair conflicts. Note that a platform-specific file is looked up and merged with the default file by default (tauri.macos.conf.json, tauri.linux.conf.json, tauri.windows.conf.json, tauri.android.conf.json and tauri.ios.conf.json) but you can use this for more specific use cases such as different build flavors. -h, --help Print help (see a summary with '-h') -V, --version Print version ``` #### `ios dev` *All iOS commands are only available on macOS hosts.* * npm ```sh npm run tauri ios dev ``` * yarn ```sh yarn tauri ios dev ``` * pnpm ```sh pnpm tauri ios dev ``` * deno ```sh deno task tauri ios dev ``` * bun ```sh bun tauri ios dev ``` * cargo ```sh cargo tauri ios dev ``` ```plaintext Run your app in development mode on iOS with hot-reloading for the Rust code. It makes use of the `build.devUrl` property from your `tauri.conf.json` file. It also runs your `build.beforeDevCommand` which usually starts your frontend devServer. When connected to a physical iOS device, the public network address must be used instead of `localhost` for the devUrl property. Tauri makes that change automatically, but your dev server might need a different configuration to listen on the public address. You can check the `TAURI_DEV_HOST` environment variable to determine whether the public network should be used or not. Usage: tauri ios dev [OPTIONS] [DEVICE] [-- ...] Arguments: [DEVICE] Runs on the given device name [ARGS]... Command line arguments passed to the runner. Use `--` to explicitly mark the start of the arguments. e.g. `tauri ios dev -- [runnerArgs]` Options: -f, --features [...] List of cargo features to activate -v, --verbose... Enables verbose logging -e, --exit-on-panic Exit on panic -c, --config JSON strings or paths to JSON, JSON5 or TOML files to merge with the default configuration file Configurations are merged in the order they are provided, which means a particular value overwrites previous values when a config key-value pair conflicts. Note that a platform-specific file is looked up and merged with the default file by default (tauri.macos.conf.json, tauri.linux.conf.json, tauri.windows.conf.json, tauri.android.conf.json and tauri.ios.conf.json) but you can use this for more specific use cases such as different build flavors. --release Run the code in release mode --no-dev-server-wait Skip waiting for the frontend dev server to start before building the tauri application [env: TAURI_CLI_NO_DEV_SERVER_WAIT=] --no-watch Disable the file watcher --additional-watch-folders Additional paths to watch for changes -o, --open Open Xcode instead of trying to run on a connected device --force-ip-prompt Force prompting for an IP to use to connect to the dev server on mobile --host [] Use the public network address for the development server. If an actual address it provided, it is used instead of prompting to pick one. This option is particularly useful along the `--open` flag when you intend on running on a physical device. This replaces the devUrl configuration value to match the public network address host, it is your responsibility to set up your development server to listen on this address by using 0.0.0.0 as host for instance. When this is set or when running on an iOS device the CLI sets the `TAURI_DEV_HOST` environment variable so you can check this on your framework's configuration to expose the development server on the public network address. [default: ] --no-dev-server Disable the built-in dev server for static files --port Specify port for the built-in dev server for static files. Defaults to 1430 [env: TAURI_CLI_PORT=] --root-certificate-path Path to the certificate file used by your dev server. Required for mobile dev when using HTTPS [env: TAURI_DEV_ROOT_CERTIFICATE_PATH=] -h, --help Print help (see a summary with '-h') -V, --version Print version ``` #### `ios build` *All iOS commands are only available on macOS hosts.* * npm ```sh npm run tauri ios build ``` * yarn ```sh yarn tauri ios build ``` * pnpm ```sh pnpm tauri ios build ``` * deno ```sh deno task tauri ios build ``` * bun ```sh bun tauri ios build ``` * cargo ```sh cargo tauri ios build ``` ```plaintext Build your app in release mode for iOS and generate IPAs. It makes use of the `build.frontendDist` property from your `tauri.conf.json` file. It also runs your `build.beforeBuildCommand` which usually builds your frontend into `build.frontendDist`. Usage: tauri ios build [OPTIONS] [-- ...] Arguments: [ARGS]... Command line arguments passed to the runner. Use `--` to explicitly mark the start of the arguments. e.g. `tauri ios build -- [runnerArgs]` Options: -d, --debug Builds with the debug flag -v, --verbose... Enables verbose logging -t, --target [...] Which targets to build [default: aarch64] [possible values: aarch64, aarch64-sim, x86_64] -f, --features [...] List of cargo features to activate -c, --config JSON strings or paths to JSON, JSON5 or TOML files to merge with the default configuration file Configurations are merged in the order they are provided, which means a particular value overwrites previous values when a config key-value pair conflicts. Note that a platform-specific file is looked up and merged with the default file by default (tauri.macos.conf.json, tauri.linux.conf.json, tauri.windows.conf.json, tauri.android.conf.json and tauri.ios.conf.json) but you can use this for more specific use cases such as different build flavors. --build-number Build number to append to the app version -o, --open Open Xcode --ci Skip prompting for values [env: CI=] --export-method Describes how Xcode should export the archive. Use this to create a package ready for the App Store (app-store-connect option) or TestFlight (release-testing option). [possible values: app-store-connect, release-testing, debugging] --ignore-version-mismatches Do not error out if a version mismatch is detected on a Tauri package. Only use this when you are sure the mismatch is incorrectly detected as version mismatched Tauri packages can lead to unknown behavior. -h, --help Print help (see a summary with '-h') -V, --version Print version ``` #### `ios run` *All iOS commands are only available on macOS hosts.* * npm ```sh npm run tauri ios run ``` * yarn ```sh yarn tauri ios run ``` * pnpm ```sh pnpm tauri ios run ``` * deno ```sh deno task tauri ios run ``` * bun ```sh bun tauri ios run ``` * cargo ```sh cargo tauri ios run ``` ```plaintext Run your app in production mode on iOS. It makes use of the `build.frontendDist` property from your `tauri.conf.json` file. It also runs your `build.beforeBuildCommand` which usually builds your frontend into `build.frontendDist`. Usage: tauri ios run [OPTIONS] [DEVICE] [-- ...] Arguments: [DEVICE] Runs on the given device name [ARGS]... Command line arguments passed to the runner. Use `--` to explicitly mark the start of the arguments. e.g. `tauri android build -- [runnerArgs]` Options: -r, --release Run the app in release mode -v, --verbose... Enables verbose logging -f, --features [...] List of cargo features to activate -c, --config JSON strings or paths to JSON, JSON5 or TOML files to merge with the default configuration file Configurations are merged in the order they are provided, which means a particular value overwrites previous values when a config key-value pair conflicts. Note that a platform-specific file is looked up and merged with the default file by default (tauri.macos.conf.json, tauri.linux.conf.json, tauri.windows.conf.json, tauri.android.conf.json and tauri.ios.conf.json) but you can use this for more specific use cases such as different build flavors. --no-watch Disable the file watcher --additional-watch-folders Additional paths to watch for changes -o, --open Open Xcode --ignore-version-mismatches Do not error out if a version mismatch is detected on a Tauri package. Only use this when you are sure the mismatch is incorrectly detected as version mismatched Tauri packages can lead to unknown behavior. -h, --help Print help (see a summary with '-h') -V, --version Print version ``` ### `migrate` * npm ```sh npm run tauri migrate ``` * yarn ```sh yarn tauri migrate ``` * pnpm ```sh pnpm tauri migrate ``` * deno ```sh deno task tauri migrate ``` * bun ```sh bun tauri migrate ``` * cargo ```sh cargo tauri migrate ``` ```plaintext Migrate from v1 to v2 Usage: tauri migrate [OPTIONS] Options: -v, --verbose... Enables verbose logging -h, --help Print help -V, --version Print version ``` ### `info` * npm ```sh npm run tauri info ``` * yarn ```sh yarn tauri info ``` * pnpm ```sh pnpm tauri info ``` * deno ```sh deno task tauri info ``` * bun ```sh bun tauri info ``` * cargo ```sh cargo tauri info ``` ```plaintext Show a concise list of information about the environment, Rust, Node.js and their versions as well as a few relevant project configurations Usage: tauri info [OPTIONS] Options: --interactive Interactive mode to apply automatic fixes -v, --verbose... Enables verbose logging -h, --help Print help -V, --version Print version ``` ### `add` * npm ```sh npm run tauri add ``` * yarn ```sh yarn tauri add ``` * pnpm ```sh pnpm tauri add ``` * deno ```sh deno task tauri add ``` * bun ```sh bun tauri add ``` * cargo ```sh cargo tauri add ``` ```plaintext Add a tauri plugin to the project Usage: tauri add [OPTIONS] Arguments: The plugin to add Options: -t, --tag Git tag to use -v, --verbose... Enables verbose logging -r, --rev Git rev to use -b, --branch Git branch to use --no-fmt Don't format code with rustfmt -h, --help Print help -V, --version Print version ``` ### `remove` * npm ```sh npm run tauri remove ``` * yarn ```sh yarn tauri remove ``` * pnpm ```sh pnpm tauri remove ``` * deno ```sh deno task tauri remove ``` * bun ```sh bun tauri remove ``` * cargo ```sh cargo tauri remove ``` ```plaintext Remove a tauri plugin from the project Usage: tauri remove [OPTIONS] Arguments: The plugin to remove Options: -v, --verbose... Enables verbose logging -h, --help Print help -V, --version Print version ``` ### `plugin` * npm ```sh npm run tauri plugin ``` * yarn ```sh yarn tauri plugin ``` * pnpm ```sh pnpm tauri plugin ``` * deno ```sh deno task tauri plugin ``` * bun ```sh bun tauri plugin ``` * cargo ```sh cargo tauri plugin ``` ```plaintext Manage or create Tauri plugins Usage: tauri plugin [OPTIONS] Commands: new Initializes a new Tauri plugin project init Initialize a Tauri plugin project on an existing directory android Manage the Android project for a Tauri plugin ios Manage the iOS project for a Tauri plugin help Print this message or the help of the given subcommand(s) Options: -v, --verbose... Enables verbose logging -h, --help Print help -V, --version Print version ``` #### `plugin new` * npm ```sh npm run tauri plugin new ``` * yarn ```sh yarn tauri plugin new ``` * pnpm ```sh pnpm tauri plugin new ``` * deno ```sh deno task tauri plugin new ``` * bun ```sh bun tauri plugin new ``` * cargo ```sh cargo tauri plugin new ``` ```plaintext Initializes a new Tauri plugin project Usage: tauri plugin new [OPTIONS] Arguments: Name of your Tauri plugin Options: --no-api Initializes a Tauri plugin without the TypeScript API -v, --verbose... Enables verbose logging --no-example Initialize without an example project -d, --directory Set target directory for init -a, --author Author name --android Whether to initialize an Android project for the plugin --ios Whether to initialize an iOS project for the plugin --mobile Whether to initialize Android and iOS projects for the plugin --ios-framework Type of framework to use for the iOS project [default: spm] Possible values: - spm: Swift Package Manager project - xcode: Xcode project --github-workflows Generate github workflows -t, --tauri-path Path of the Tauri project to use (relative to the cwd) -h, --help Print help (see a summary with '-h') -V, --version Print version ``` #### `plugin init` * npm ```sh npm run tauri plugin init ``` * yarn ```sh yarn tauri plugin init ``` * pnpm ```sh pnpm tauri plugin init ``` * deno ```sh deno task tauri plugin init ``` * bun ```sh bun tauri plugin init ``` * cargo ```sh cargo tauri plugin init ``` ```plaintext Initialize a Tauri plugin project on an existing directory Usage: tauri plugin init [OPTIONS] [PLUGIN_NAME] Arguments: [PLUGIN_NAME] Name of your Tauri plugin. If not specified, it will be inferred from the current directory Options: --no-api Initializes a Tauri plugin without the TypeScript API -v, --verbose... Enables verbose logging --no-example Initialize without an example project -d, --directory Set target directory for init [default: /opt/build/repo/packages/cli-generator] -a, --author Author name --android Whether to initialize an Android project for the plugin --ios Whether to initialize an iOS project for the plugin --mobile Whether to initialize Android and iOS projects for the plugin --ios-framework Type of framework to use for the iOS project [default: spm] Possible values: - spm: Swift Package Manager project - xcode: Xcode project --github-workflows Generate github workflows -t, --tauri-path Path of the Tauri project to use (relative to the cwd) -h, --help Print help (see a summary with '-h') -V, --version Print version ``` #### `plugin android` * npm ```sh npm run tauri plugin android ``` * yarn ```sh yarn tauri plugin android ``` * pnpm ```sh pnpm tauri plugin android ``` * deno ```sh deno task tauri plugin android ``` * bun ```sh bun tauri plugin android ``` * cargo ```sh cargo tauri plugin android ``` ```plaintext Manage the Android project for a Tauri plugin Usage: tauri plugin android [OPTIONS] Commands: init Initializes the Android project for an existing Tauri plugin help Print this message or the help of the given subcommand(s) Options: -v, --verbose... Enables verbose logging -h, --help Print help -V, --version Print version ``` ##### `plugin android init` * npm ```sh npm run tauri plugin android init ``` * yarn ```sh yarn tauri plugin android init ``` * pnpm ```sh pnpm tauri plugin android init ``` * deno ```sh deno task tauri plugin android init ``` * bun ```sh bun tauri plugin android init ``` * cargo ```sh cargo tauri plugin android init ``` ```plaintext Initializes the Android project for an existing Tauri plugin Usage: tauri plugin android init [OPTIONS] [PLUGIN_NAME] Arguments: [PLUGIN_NAME] Name of your Tauri plugin. Must match the current plugin's name. If not specified, it will be inferred from the current directory Options: -o, --out-dir The output directory [default: /opt/build/repo/packages/cli-generator] -v, --verbose... Enables verbose logging -h, --help Print help -V, --version Print version ``` #### `plugin ios` * npm ```sh npm run tauri plugin ios ``` * yarn ```sh yarn tauri plugin ios ``` * pnpm ```sh pnpm tauri plugin ios ``` * deno ```sh deno task tauri plugin ios ``` * bun ```sh bun tauri plugin ios ``` * cargo ```sh cargo tauri plugin ios ``` ```plaintext Manage the iOS project for a Tauri plugin Usage: tauri plugin ios [OPTIONS] Commands: init Initializes the iOS project for an existing Tauri plugin help Print this message or the help of the given subcommand(s) Options: -v, --verbose... Enables verbose logging -h, --help Print help -V, --version Print version ``` ##### `plugin ios init` * npm ```sh npm run tauri plugin ios init ``` * yarn ```sh yarn tauri plugin ios init ``` * pnpm ```sh pnpm tauri plugin ios init ``` * deno ```sh deno task tauri plugin ios init ``` * bun ```sh bun tauri plugin ios init ``` * cargo ```sh cargo tauri plugin ios init ``` ```plaintext Initializes the iOS project for an existing Tauri plugin Usage: tauri plugin ios init [OPTIONS] [PLUGIN_NAME] Arguments: [PLUGIN_NAME] Name of your Tauri plugin. Must match the current plugin's name. If not specified, it will be inferred from the current directory Options: -o, --out-dir The output directory [default: /opt/build/repo/packages/cli-generator] -v, --verbose... Enables verbose logging --ios-framework Type of framework to use for the iOS project [default: spm] Possible values: - spm: Swift Package Manager project - xcode: Xcode project -h, --help Print help (see a summary with '-h') -V, --version Print version ``` ### `icon` * npm ```sh npm run tauri icon ``` * yarn ```sh yarn tauri icon ``` * pnpm ```sh pnpm tauri icon ``` * deno ```sh deno task tauri icon ``` * bun ```sh bun tauri icon ``` * cargo ```sh cargo tauri icon ``` ```plaintext Generate various icons for all major platforms Usage: tauri icon [OPTIONS] [INPUT] Arguments: [INPUT] Path to the source icon (squared PNG or SVG file with transparency) or a manifest file. The manifest file is a JSON file with the following structure: { "default": "app-icon.png", "bg_color": "#fff", "android_bg": "app-icon-bg.png", "android_fg": "app-icon-fg.png", "android_fg_scale": 85, "android_monochrome": "app-icon-monochrome.png" } All file paths defined in the manifest JSON are relative to the manifest file path. Only the `default` manifest property is required. The `bg_color` manifest value overwrites the `--ios-color` option if set. [default: ./app-icon.png] Options: -o, --output Output directory. Default: 'icons' directory next to the tauri.conf.json file -v, --verbose... Enables verbose logging -p, --png Custom PNG icon sizes to generate. When set, the default icons are not generated --ios-color The background color of the iOS icon - string as defined in the W3C's CSS Color Module Level 4 [default: #fff] -h, --help Print help (see a summary with '-h') -V, --version Print version ``` ### `signer` * npm ```sh npm run tauri signer ``` * yarn ```sh yarn tauri signer ``` * pnpm ```sh pnpm tauri signer ``` * deno ```sh deno task tauri signer ``` * bun ```sh bun tauri signer ``` * cargo ```sh cargo tauri signer ``` ```plaintext Generate signing keys for Tauri updater or sign files Usage: tauri signer [OPTIONS] Commands: sign Sign a file generate Generate a new signing key to sign files help Print this message or the help of the given subcommand(s) Options: -v, --verbose... Enables verbose logging -h, --help Print help -V, --version Print version ``` #### `signer sign` * npm ```sh npm run tauri signer sign ``` * yarn ```sh yarn tauri signer sign ``` * pnpm ```sh pnpm tauri signer sign ``` * deno ```sh deno task tauri signer sign ``` * bun ```sh bun tauri signer sign ``` * cargo ```sh cargo tauri signer sign ``` ```plaintext Sign a file Usage: tauri signer sign [OPTIONS] Arguments: Sign the specified file Options: -k, --private-key Load the private key from a string [env: TAURI_SIGNING_PRIVATE_KEY=] -v, --verbose... Enables verbose logging -f, --private-key-path Load the private key from a file [env: TAURI_SIGNING_PRIVATE_KEY_PATH=] -p, --password Set private key password when signing [env: TAURI_SIGNING_PRIVATE_KEY_PASSWORD=] -h, --help Print help -V, --version Print version ``` #### `signer generate` * npm ```sh npm run tauri signer generate ``` * yarn ```sh yarn tauri signer generate ``` * pnpm ```sh pnpm tauri signer generate ``` * deno ```sh deno task tauri signer generate ``` * bun ```sh bun tauri signer generate ``` * cargo ```sh cargo tauri signer generate ``` ```plaintext Generate a new signing key to sign files Usage: tauri signer generate [OPTIONS] Options: -p, --password Set private key password when signing -v, --verbose... Enables verbose logging -w, --write-keys Write private key to a file -f, --force Overwrite private key even if it exists on the specified path --ci Skip prompting for values [env: CI=true] -h, --help Print help -V, --version Print version ``` ### `completions` * npm ```sh npm run tauri completions ``` * yarn ```sh yarn tauri completions ``` * pnpm ```sh pnpm tauri completions ``` * deno ```sh deno task tauri completions ``` * bun ```sh bun tauri completions ``` * cargo ```sh cargo tauri completions ``` ```plaintext Generate Tauri CLI shell completions for Bash, Zsh, PowerShell or Fish Usage: tauri completions [OPTIONS] --shell Options: -s, --shell Shell to generate a completion script for. [possible values: bash, elvish, fish, powershell, zsh] -v, --verbose... Enables verbose logging -o, --output Output file for the shell completions. By default the completions are printed to stdout -h, --help Print help -V, --version Print version ``` ### `permission` * npm ```sh npm run tauri permission ``` * yarn ```sh yarn tauri permission ``` * pnpm ```sh pnpm tauri permission ``` * deno ```sh deno task tauri permission ``` * bun ```sh bun tauri permission ``` * cargo ```sh cargo tauri permission ``` ```plaintext Manage or create permissions for your app or plugin Usage: tauri permission [OPTIONS] Commands: new Create a new permission file add Add a permission to capabilities rm Remove a permission file, and its reference from any capability ls List permissions available to your application help Print this message or the help of the given subcommand(s) Options: -v, --verbose... Enables verbose logging -h, --help Print help -V, --version Print version ``` #### `permission new` * npm ```sh npm run tauri permission new ``` * yarn ```sh yarn tauri permission new ``` * pnpm ```sh pnpm tauri permission new ``` * deno ```sh deno task tauri permission new ``` * bun ```sh bun tauri permission new ``` * cargo ```sh cargo tauri permission new ``` ```plaintext Create a new permission file Usage: tauri permission new [OPTIONS] [IDENTIFIER] Arguments: [IDENTIFIER] Permission identifier Options: --description Permission description -v, --verbose... Enables verbose logging -a, --allow List of commands to allow -d, --deny List of commands to deny --format Output file format [default: json] [possible values: json, toml] -o, --out The output file -h, --help Print help -V, --version Print version ``` #### `permission add` * npm ```sh npm run tauri permission add ``` * yarn ```sh yarn tauri permission add ``` * pnpm ```sh pnpm tauri permission add ``` * deno ```sh deno task tauri permission add ``` * bun ```sh bun tauri permission add ``` * cargo ```sh cargo tauri permission add ``` ```plaintext Add a permission to capabilities Usage: tauri permission add [OPTIONS] [CAPABILITY] Arguments: Permission to add [CAPABILITY] Capability to add the permission to Options: -v, --verbose... Enables verbose logging -h, --help Print help -V, --version Print version ``` #### `permission rm` * npm ```sh npm run tauri permission rm ``` * yarn ```sh yarn tauri permission rm ``` * pnpm ```sh pnpm tauri permission rm ``` * deno ```sh deno task tauri permission rm ``` * bun ```sh bun tauri permission rm ``` * cargo ```sh cargo tauri permission rm ``` ```plaintext Remove a permission file, and its reference from any capability Usage: tauri permission rm [OPTIONS] Arguments: Permission to remove. To remove all permissions for a given plugin, provide `:*` Options: -v, --verbose... Enables verbose logging -h, --help Print help (see a summary with '-h') -V, --version Print version ``` #### `permission ls` * npm ```sh npm run tauri permission ls ``` * yarn ```sh yarn tauri permission ls ``` * pnpm ```sh pnpm tauri permission ls ``` * deno ```sh deno task tauri permission ls ``` * bun ```sh bun tauri permission ls ``` * cargo ```sh cargo tauri permission ls ``` ```plaintext List permissions available to your application Usage: tauri permission ls [OPTIONS] [PLUGIN] Arguments: [PLUGIN] Name of the plugin to list permissions Options: -f, --filter Permission identifier filter -v, --verbose... Enables verbose logging -h, --help Print help -V, --version Print version ``` ### `capability` * npm ```sh npm run tauri capability ``` * yarn ```sh yarn tauri capability ``` * pnpm ```sh pnpm tauri capability ``` * deno ```sh deno task tauri capability ``` * bun ```sh bun tauri capability ``` * cargo ```sh cargo tauri capability ``` ```plaintext Manage or create capabilities for your app Usage: tauri capability [OPTIONS] Commands: new Create a new permission file help Print this message or the help of the given subcommand(s) Options: -v, --verbose... Enables verbose logging -h, --help Print help -V, --version Print version ``` #### `capability new` * npm ```sh npm run tauri capability new ``` * yarn ```sh yarn tauri capability new ``` * pnpm ```sh pnpm tauri capability new ``` * deno ```sh deno task tauri capability new ``` * bun ```sh bun tauri capability new ``` * cargo ```sh cargo tauri capability new ``` ```plaintext Create a new permission file Usage: tauri capability new [OPTIONS] [IDENTIFIER] Arguments: [IDENTIFIER] Capability identifier Options: --description Capability description -v, --verbose... Enables verbose logging --windows Capability windows --permission Capability permissions --format Output file format [default: json] [possible values: json, toml] -o, --out The output file -h, --help Print help -V, --version Print version ``` ### `inspect` * npm ```sh npm run tauri inspect ``` * yarn ```sh yarn tauri inspect ``` * pnpm ```sh pnpm tauri inspect ``` * deno ```sh deno task tauri inspect ``` * bun ```sh bun tauri inspect ``` * cargo ```sh cargo tauri inspect ``` ```plaintext Inspect values used by Tauri Usage: tauri inspect [OPTIONS] Commands: wix-upgrade-code Print the default Upgrade Code used by MSI installer derived from productName help Print this message or the help of the given subcommand(s) Options: -v, --verbose... Enables verbose logging -h, --help Print help -V, --version Print version ``` #### `inspect wix-upgrade-code` * npm ```sh npm run tauri inspect wix-upgrade-code ``` * yarn ```sh yarn tauri inspect wix-upgrade-code ``` * pnpm ```sh pnpm tauri inspect wix-upgrade-code ``` * deno ```sh deno task tauri inspect wix-upgrade-code ``` * bun ```sh bun tauri inspect wix-upgrade-code ``` * cargo ```sh cargo tauri inspect wix-upgrade-code ``` ```plaintext Print the default Upgrade Code used by MSI installer derived from productName Usage: tauri inspect wix-upgrade-code [OPTIONS] Options: -v, --verbose... Enables verbose logging -h, --help Print help -V, --version Print version ``` # Configuration The Tauri configuration object. It is read from a file where you can define your frontend assets, configure the bundler and define a tray icon. The configuration file is generated by the [`tauri init`](https://v2.tauri.app/reference/cli/#init) command that lives in your Tauri application source directory (src-tauri). Once generated, you may modify it at will to customize your Tauri application. ### File Formats By default, the configuration is defined as a JSON file named `tauri.conf.json`. Tauri also supports JSON5 and TOML files via the `config-json5` and `config-toml` Cargo features, respectively. The JSON5 file name must be either `tauri.conf.json` or `tauri.conf.json5`. The TOML file name is `Tauri.toml`. ### Platform-Specific Configuration In addition to the default configuration file, Tauri can read a platform-specific configuration from `tauri.linux.conf.json`, `tauri.windows.conf.json`, `tauri.macos.conf.json`, `tauri.android.conf.json` and `tauri.ios.conf.json` (or `Tauri.linux.toml`, `Tauri.windows.toml`, `Tauri.macos.toml`, `Tauri.android.toml` and `Tauri.ios.toml` if the `Tauri.toml` format is used), which gets merged with the main configuration object. ### Configuration Structure The configuration is composed of the following objects: * [`app`](#appconfig): The Tauri configuration * [`build`](#buildconfig): The build configuration * [`bundle`](#bundleconfig): The bundle configurations * [`plugins`](#pluginconfig): The plugins configuration Example tauri.config.json file: ```json { "productName": "tauri-app", "version": "0.1.0", "build": { "beforeBuildCommand": "", "beforeDevCommand": "", "devUrl": "http://localhost:3000", "frontendDist": "../dist" }, "app": { "security": { "csp": null }, "windows": [ { "fullscreen": false, "height": 600, "resizable": true, "title": "Tauri App", "width": 800 } ] }, "bundle": {}, "plugins": {} } ``` **Object Properties**: * app * build * bundle * identifier (required) * mainBinaryName * plugins * productName * version ### app [`AppConfig`](#appconfig) The App configuration. Default ```json { "enableGTKAppId": false, "macOSPrivateApi": false, "security": { "assetProtocol": { "enable": false, "scope": [] }, "capabilities": [], "dangerousDisableAssetCspModification": false, "freezePrototype": false, "pattern": { "use": "brownfield" } }, "windows": [], "withGlobalTauri": false } ``` ### build [`BuildConfig`](#buildconfig) The build configuration. Default ```json { "additionalWatchFolders": [], "removeUnusedCommands": false, "windows": { "staticVCRuntime": true } } ``` ### bundle [`BundleConfig`](#bundleconfig) The bundler configuration. Default ```json { "active": false, "android": { "autoIncrementVersionCode": false, "minSdkVersion": 24 }, "createUpdaterArtifacts": false, "iOS": { "minimumSystemVersion": "14.0" }, "icon": [], "linux": { "appimage": { "bundleMediaFramework": false, "files": {} }, "deb": { "files": {} }, "rpm": { "epoch": 0, "files": {}, "release": "1" } }, "macOS": { "dmg": { "appPosition": { "x": 180, "y": 170 }, "applicationFolderPosition": { "x": 480, "y": 170 }, "windowSize": { "height": 400, "width": 660 } }, "files": {}, "hardenedRuntime": true, "minimumSystemVersion": "10.13" }, "targets": "all", "useLocalToolsDir": false, "windows": { "allowDowngrades": true, "bundleVCRuntime": false, "certificateThumbprint": null, "digestAlgorithm": null, "minimumWebview2Version": null, "nsis": null, "signCommand": null, "timestampUrl": null, "tsp": false, "webviewInstallMode": { "silent": true, "type": "downloadBootstrapper" }, "wix": null } } ``` ### identifier `string` The application identifier in reverse domain name notation (e.g. `com.tauri.example`). This string must be unique across applications since it is used in system configurations like the bundle ID and path to the webview data directory. This string must contain only alphanumeric characters (A-Z, a-z, and 0-9), hyphens (-), and periods (.). ### mainBinaryName `string` | `null` Overrides app’s main binary filename. By default, Tauri uses the output binary from `cargo`, by setting this, we will rename that binary in `tauri-cli`’s `tauri build` command, and target `tauri bundle` to it If possible, change the [`package name`](https://doc.rust-lang.org/cargo/reference/manifest.html#the-name-field) or set the [`name field`](https://doc.rust-lang.org/cargo/reference/cargo-targets.html#the-name-field) instead, and if that’s not enough and you’re using nightly, consider using the [`different-binary-name`](https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#different-binary-name) feature instead Note: this config should not include the binary extension (e.g. `.exe`), we’ll add that for you ### plugins [`PluginConfig`](#pluginconfig) The plugins config. **Default**: `{}` ### productName `string` | `null` pattern of `^[^/\:*?"<>|]+$` App name. ### version `string` | `null` App version. It is a semver version number or a path to a `package.json` file containing the `version` field. If removed the version number from `Cargo.toml` is used. It’s recommended to manage the app versioning in the Tauri config. #### Platform-specific * **macOS**: Translates to the bundle’s CFBundleShortVersionString property and is used as the default CFBundleVersion. You can set an specific bundle version using [`bundle > macOS > bundleVersion`](MacConfig::bundle_version). * **iOS**: Translates to the bundle’s CFBundleShortVersionString property and is used as the default CFBundleVersion. You can set an specific bundle version using [`bundle > iOS > bundleVersion`](IosConfig::bundle_version). The `tauri ios build` CLI command has a `--build-number <number>` option that lets you append a build number to the app version. * **Android**: By default version 1.0 is used. You can set a version code using [`bundle > android > versionCode`](AndroidConfig::version_code). By default version 1.0 is used on Android. ## Definitions ### AndroidConfig General configuration for the Android target. **Object Properties**: * autoIncrementVersionCode * debugApplicationIdSuffix * minSdkVersion * versionCode ##### autoIncrementVersionCode `boolean` Whether to automatically increment the `versionCode` on each build. * If `true`, the generator will try to read the last `versionCode` from `tauri.properties` and increment it by 1 for every build. * If `false` or not set, it falls back to `version_code` or semver-derived logic. Note that to use this feature, you should remove `/tauri.properties` from `src-tauri/gen/android/app/.gitignore` so the current versionCode is committed to the repository. ##### debugApplicationIdSuffix `string` | `null` Application ID suffix to append for debug builds. This allows installing debug and release versions side-by-side on the same device. Example: “.debug” will make debug builds use “com.example.app.debug” as the application ID. ##### minSdkVersion `integer` formatted as `uint32` The minimum API level required for the application to run. The Android system will prevent the user from installing the application if the system’s API level is lower than the value specified. **Default**: `24` ##### versionCode `integer` | `null` maximum of `2100000000`, minimum of `1`, formatted as `uint32` The version code of the application. It is limited to 2,100,000,000 as per Google Play Store requirements. By default we use your configured version and perform the following math: versionCode = version.major \* 1000000 + version.minor \* 1000 + version.patch ### AndroidIntentAction **One of the following**: * `"send"` ACTION\_SEND. <> * `"sendMultiple"` ACTION\_SEND\_MULTIPLE. <> * `"view"` ACTION\_VIEW. <> Android intent action. ### AppConfig The App configuration object. See more: <> **Object Properties**: * enableGTKAppId * macOSPrivateApi * security * trayIcon * windows * withGlobalTauri ##### enableGTKAppId `boolean` If set to true “identifier” will be set as GTK app ID (on systems that use GTK). ##### macOSPrivateApi `boolean` MacOS private API configuration. Enables the transparent background API and sets the `fullScreenEnabled` preference to `true`. ##### security [`SecurityConfig`](#securityconfig) Security configuration. Default ```json { "assetProtocol": { "enable": false, "scope": [] }, "capabilities": [], "dangerousDisableAssetCspModification": false, "freezePrototype": false, "pattern": { "use": "brownfield" } } ``` ##### trayIcon [`TrayIconConfig`](#trayiconconfig) | `null` Configuration for app tray icon. ##### windows [`WindowConfig`](#windowconfig)\[] The app windows configuration. ###### Example: To create a window at app startup ```json { "app": { "windows": [ { "width": 800, "height": 600 } ] } } ``` If not specified, the window’s label (its identifier) defaults to “main”, you can use this label to get the window through `app.get_webview_window` in Rust or `WebviewWindow.getByLabel` in JavaScript When working with multiple windows, each window will need an unique label ```json { "app": { "windows": [ { "label": "main", "width": 800, "height": 600 }, { "label": "secondary", "width": 800, "height": 600 } ] } } ``` You can also set `create` to false and use this config through the Rust APIs ```json { "app": { "windows": [ { "create": false, "width": 800, "height": 600 } ] } } ``` and use it like this ```rust tauri::Builder::default() .setup(|app| { tauri::WebviewWindowBuilder::from_config(app.handle(), &app.config().app.windows[0])?.build()?; Ok(()) }); ``` **Default**: `[]` ##### withGlobalTauri `boolean` Whether we should inject the Tauri API on `window.__TAURI__` or not. ### AppImageConfig Configuration for AppImage bundles. See more: <> **Object Properties**: * bundleMediaFramework * files ##### bundleMediaFramework `boolean` Include additional gstreamer dependencies needed for audio and video playback. This increases the bundle size by \~15-35MB depending on your build system. ##### files The files to include in the Appimage Binary. **Allows additional properties**: `string` **Default**: `{}` ### AssetProtocolConfig Config for the asset custom protocol. See more: <> **Object Properties**: * enable * scope ##### enable `boolean` Enables the asset protocol. ##### scope [`FsScope`](#fsscope) The access scope for the asset protocol. **Default**: `[]` ### AssociationExt `string` An extension for a \[`FileAssociation`]. A leading `.` is automatically stripped. ### BackgroundThrottlingPolicy **One of the following**: * `"disabled"` A policy where background throttling is disabled * `"suspend"` A policy where a web view that’s not in a window fully suspends tasks. This is usually the default behavior in case no policy is set. * `"throttle"` A policy where a web view that’s not in a window limits processing, but does not fully suspend tasks. Background throttling policy. ### BeforeDevCommand **Any of the following**: * `string` Run the given script with the default options. * Run the given script with custom options. **Object Properties**: - cwd - script (required) - wait ##### cwd `string` | `null` The current working directory. ##### script `string` The script to execute. ##### wait `boolean` Whether `tauri dev` should wait for the command to finish or not. Defaults to `false`. Describes the shell command to run before `tauri dev`. ### BuildConfig The Build configuration object. See more: <> **Object Properties**: * additionalWatchFolders * beforeBuildCommand * beforeBundleCommand * beforeDevCommand * devUrl * features * frontendDist * removeUnusedCommands * runner * windows ##### additionalWatchFolders `string`\[] Additional paths to watch for changes when running `tauri dev`. **Default**: `[]` ##### beforeBuildCommand [`HookCommand`](#hookcommand) | `null` A shell command to run before `tauri build` kicks in. The TAURI\_ENV\_PLATFORM, TAURI\_ENV\_ARCH, TAURI\_ENV\_FAMILY, TAURI\_ENV\_PLATFORM\_VERSION, TAURI\_ENV\_PLATFORM\_TYPE and TAURI\_ENV\_DEBUG environment variables are set if you perform conditional compilation. ##### beforeBundleCommand [`HookCommand`](#hookcommand) | `null` A shell command to run before the bundling phase in `tauri build` kicks in. The TAURI\_ENV\_PLATFORM, TAURI\_ENV\_ARCH, TAURI\_ENV\_FAMILY, TAURI\_ENV\_PLATFORM\_VERSION, TAURI\_ENV\_PLATFORM\_TYPE and TAURI\_ENV\_DEBUG environment variables are set if you perform conditional compilation. ##### beforeDevCommand [`BeforeDevCommand`](#beforedevcommand) | `null` A shell command to run before `tauri dev` kicks in. The TAURI\_ENV\_PLATFORM, TAURI\_ENV\_ARCH, TAURI\_ENV\_FAMILY, TAURI\_ENV\_PLATFORM\_VERSION, TAURI\_ENV\_PLATFORM\_TYPE and TAURI\_ENV\_DEBUG environment variables are set if you perform conditional compilation. ##### devUrl `string` | `null` formatted as `uri` The URL to load in development. This is usually an URL to a dev server, which serves your application assets with hot-reload and HMR. Most modern JavaScript bundlers like [Vite](https://vite.dev/guide/) provides a way to start a dev server by default. If you don’t have a dev server or don’t want to use one, ignore this option and use [`frontendDist`](BuildConfig::frontend_dist) and point to a web assets directory, and Tauri CLI will run its built-in dev server and provide a simple hot-reload experience. ##### features `string`\[] | `null` Features passed to `cargo` commands. ##### frontendDist [`FrontendDist`](#frontenddist) | `null` The path to the application assets (usually the `dist` folder of your javascript bundler) or a URL that could be either a custom protocol registered in the tauri app (for example: `myprotocol://`) or a remote URL (for example: `https://site.com/app`). When a path relative to the configuration file is provided, it is read recursively and all files are embedded in the application binary. Tauri then looks for an `index.html` and serves it as the default entry point for your application. You can also provide a list of paths to be embedded, which allows granular control over what files are added to the binary. In this case, all files are added to the root and you must reference it that way in your HTML files. When a URL is provided, the application won’t have bundled assets and the application will load that URL by default. ##### removeUnusedCommands `boolean` Try to remove unused commands registered from plugins base on the ACL list during `tauri build`, the way it works is that tauri-cli will read this and set the environment variables for the build script and macros, and they’ll try to get all the allowed commands and remove the rest Note: * This won’t be accounting for dynamically added ACLs when you use features from the `dynamic-acl` (currently enabled by default) feature flag, so make sure to check it when using this * This feature requires tauri-plugin 2.1 and tauri 2.4 ##### runner [`RunnerConfig`](#runnerconfig) | `null` The binary used to build and run the application. ##### windows [`WindowsBuildConfig`](#windowsbuildconfig) Windows-specific build configuration. Default ```json { "staticVCRuntime": true } ``` ### BundleConfig Configuration for tauri-bundler. See more: <> **Object Properties**: * active * android * category * copyright * createUpdaterArtifacts * externalBin * fileAssociations * homepage * icon * iOS * license * licenseFile * linux * longDescription * macOS * publisher * resources * shortDescription * targets * useLocalToolsDir * windows ##### active `boolean` Whether Tauri should bundle your application or just output the executable. ##### android [`AndroidConfig`](#androidconfig) Android configuration. Default ```json { "autoIncrementVersionCode": false, "minSdkVersion": 24 } ``` ##### category `string` | `null` The application kind. Should be one of the following: Business, DeveloperTool, Education, Entertainment, Finance, Game, ActionGame, AdventureGame, ArcadeGame, BoardGame, CardGame, CasinoGame, DiceGame, EducationalGame, FamilyGame, KidsGame, MusicGame, PuzzleGame, RacingGame, RolePlayingGame, SimulationGame, SportsGame, StrategyGame, TriviaGame, WordGame, GraphicsAndDesign, HealthcareAndFitness, Lifestyle, Medical, Music, News, Photography, Productivity, Reference, SocialNetworking, Sports, Travel, Utility, Video, Weather. ##### copyright `string` | `null` A copyright string associated with your application. ##### createUpdaterArtifacts [`Updater`](#updater) Produce updaters and their signatures or not ##### externalBin `string`\[] | `null` A list of—either absolute or relative—paths to binaries to embed with your application. Note that Tauri will look for system-specific binaries following the pattern “binary-name{-target-triple}{.system-extension}”. E.g. for the external binary “my-binary”, Tauri looks for: * “my-binary-x86\_64-pc-windows-msvc.exe” for Windows * “my-binary-x86\_64-apple-darwin” for macOS * “my-binary-x86\_64-unknown-linux-gnu” for Linux so don’t forget to provide binaries for all targeted platforms. ##### fileAssociations [`FileAssociation`](#fileassociation)\[] | `null` File types to associate with the application. ##### homepage `string` | `null` A url to the home page of your application. If unset, will fallback to `homepage` defined in `Cargo.toml`. Supported bundle targets: `deb`, `rpm`, `nsis` and `msi`. ##### icon `string`\[] The app’s icons **Default**: `[]` ##### iOS [`IosConfig`](#iosconfig) iOS configuration. Default ```json { "minimumSystemVersion": "14.0" } ``` ##### license `string` | `null` The package’s license identifier to be included in the appropriate bundles. If not set, defaults to the license from the Cargo.toml file. ##### licenseFile `string` | `null` The path to the license file to be included in the appropriate bundles. ##### linux [`LinuxConfig`](#linuxconfig) Configuration for the Linux bundles. Default ```json { "appimage": { "bundleMediaFramework": false, "files": {} }, "deb": { "files": {} }, "rpm": { "epoch": 0, "files": {}, "release": "1" } } ``` ##### longDescription `string` | `null` A longer, multi-line description of the application. ##### macOS [`MacConfig`](#macconfig) Configuration for the macOS bundles. Default ```json { "dmg": { "appPosition": { "x": 180, "y": 170 }, "applicationFolderPosition": { "x": 480, "y": 170 }, "windowSize": { "height": 400, "width": 660 } }, "files": {}, "hardenedRuntime": true, "minimumSystemVersion": "10.13" } ``` ##### publisher `string` | `null` The application’s publisher. Defaults to the second element in the identifier string. Currently maps to the Manufacturer property of the Windows Installer and the Maintainer field of debian packages if the Cargo.toml does not have the authors field. ##### resources [`BundleResources`](#bundleresources) | `null` App resources to bundle. Each resource is a path to a file or directory. Glob patterns are supported. ###### Examples To include a list of files: ```json { "bundle": { "resources": [ "./path/to/some-file.txt", "/absolute/path/to/textfile.txt", "../relative/path/to/jsonfile.json", "some-folder/", "resources/**/*.md" ] } } ``` The bundled files will be in `$RESOURCES/` with the original directory structure preserved, for example: `./path/to/some-file.txt` -> `$RESOURCE/path/to/some-file.txt` To fine control where the files will get copied to, use a map instead ```json { "bundle": { "resources": { "/absolute/path/to/textfile.txt": "resources/textfile.txt", "relative/path/to/jsonfile.json": "resources/jsonfile.json", "resources/": "", "docs/**/*md": "website-docs/" } } } ``` Note that when using glob pattern in this case, the original directory structure is not preserved, everything gets copied to the target directory directly See more: <> ##### shortDescription `string` | `null` A short description of your application. ##### targets [`BundleTarget`](#bundletarget) The bundle targets, currently supports \[“deb”, “rpm”, “appimage”, “nsis”, “msi”, “app”, “dmg”] or “all”. **Default**: `"all"` ##### useLocalToolsDir `boolean` Whether to use the project’s `target` directory, for caching build tools (e.g., Wix and NSIS) when building this application. Defaults to `false`. If true, tools will be cached in `target/.tauri/`. If false, tools will be cached in the current user’s platform-specific cache directory. An example where it can be appropriate to set this to `true` is when building this application as a Windows System user (e.g., AWS EC2 workloads), because the Window system’s app data directory is restricted. ##### windows [`WindowsConfig`](#windowsconfig) Configuration for the Windows bundles. Default ```json { "allowDowngrades": true, "bundleVCRuntime": false, "certificateThumbprint": null, "digestAlgorithm": null, "minimumWebview2Version": null, "nsis": null, "signCommand": null, "timestampUrl": null, "tsp": false, "webviewInstallMode": { "silent": true, "type": "downloadBootstrapper" }, "wix": null } ``` ### BundleResources **Any of the following**: * `string`\[] A list of paths to include. * A map of source to target paths. **Allows additional properties**: `string` Definition for bundle resources. Can be either a list of paths to include or a map of source to target paths. ### BundleTarget **Any of the following**: * `"all"` Bundle all targets. * [`BundleType`](#bundletype)\[] A list of bundle targets. * [`BundleType`](#bundletype) A single bundle target. Targets to bundle. Each value is case insensitive. ### BundleType **One of the following**: * `"deb"` The debian bundle (.deb). * `"rpm"` The RPM bundle (.rpm). * `"appimage"` The AppImage bundle (.appimage). * `"msi"` The Microsoft Installer bundle (.msi). * `"nsis"` The NSIS bundle (.exe). * `"app"` The macOS application bundle (.app). * `"dmg"` The Apple Disk Image bundle (.dmg). A bundle referenced by tauri-bundler. ### BundleTypeRole **One of the following**: * `"Editor"` CFBundleTypeRole.Editor. Files can be read and edited. * `"Viewer"` CFBundleTypeRole.Viewer. Files can be read. * `"Shell"` CFBundleTypeRole.Shell * `"QLGenerator"` CFBundleTypeRole.QLGenerator * `"None"` CFBundleTypeRole.None macOS-only. Corresponds to CFBundleTypeRole ### Capability A grouping and boundary mechanism developers can use to isolate access to the IPC layer. It controls application windows’ and webviews’ fine grained access to the Tauri core, application, or plugin commands. If a webview or its window is not matching any capability then it has no access to the IPC layer at all. This can be done to create groups of windows, based on their required system access, which can reduce impact of frontend vulnerabilities in less privileged windows. Windows can be added to a capability by exact name (e.g. `main-window`) or glob patterns like `*` or `admin-*`. A Window can have none, one, or multiple associated capabilities. ##### Example ```json { "identifier": "main-user-files-write", "description": "This capability allows the `main` window on macOS and Windows access to `filesystem` write related commands and `dialog` commands to enable programmatic access to files selected by the user.", "windows": [ "main" ], "permissions": [ "core:default", "dialog:open", { "identifier": "fs:allow-write-text-file", "allow": [{ "path": "$HOME/test.txt" }] }, ], "platforms": ["macOS","windows"] } ``` **Object Properties**: * description * identifier (required) * local * permissions (required) * platforms * remote * webviews * windows ##### description `string` Description of what the capability is intended to allow on associated windows. It should contain a description of what the grouped permissions should allow. ###### Example This capability allows the `main` window access to `filesystem` write related commands and `dialog` commands to enable programmatic access to files selected by the user. ##### identifier `string` Identifier of the capability. ###### Example `main-user-files-write` ##### local `boolean` Whether this capability is enabled for local app URLs or not. Defaults to `true`. **Default**: `true` ##### permissions [`PermissionEntry`](#permissionentry)\[] each item must be unique List of permissions attached to this capability. Must include the plugin name as prefix in the form of `${plugin-name}:${permission-name}`. For commands directly implemented in the application itself only `${permission-name}` is required. ###### Example ```json [ "core:default", "shell:allow-open", "dialog:open", { "identifier": "fs:allow-write-text-file", "allow": [{ "path": "$HOME/test.txt" }] } ] ``` ##### platforms [`Target`](#target)\[] | `null` Limit which target platforms this capability applies to. By default all platforms are targeted. ###### Example `["macOS","windows"]` ##### remote [`CapabilityRemote`](#capabilityremote) | `null` Configure remote URLs that can use the capability permissions. This setting is optional and defaults to not being set, as our default use case is that the content is served from our local application. Caution Make sure you understand the security implications of providing remote sources with local system access. ###### Example ```json { "urls": ["https://*.mydomain.dev"] } ``` ##### webviews `string`\[] List of webviews that are affected by this capability. Can be a glob pattern. The capability will be enabled on all the webviews whose label matches any of the patterns in this list, regardless of whether the webview’s window label matches a pattern in \[`Self::windows`]. ###### Example `["sub-webview-one", "sub-webview-two"]` ##### windows `string`\[] List of windows that are affected by this capability. Can be a glob pattern. If a window label matches any of the patterns in this list, the capability will be enabled on all the webviews of that window, regardless of the value of \[`Self::webviews`]. On multiwebview windows, prefer specifying \[`Self::webviews`] and omitting \[`Self::windows`] for a fine grained access control. ###### Example `["main"]` ### CapabilityEntry **Any of the following**: * [`Capability`](#capability) An inlined capability. * `string` Reference to a capability identifier. A capability entry which can be either an inlined capability or a reference to a capability defined on its own file. ### CapabilityRemote Configuration for remote URLs that are associated with the capability. **Object Properties**: * urls (required) ##### urls `string`\[] Remote domains this capability refers to using the [URLPattern standard](https://urlpattern.spec.whatwg.org/). ###### Examples * “https\://\*.mydomain.dev”: allows subdomains of mydomain.dev * “\*”: allows any subpath of mydomain.dev/api ### Color **Any of the following**: * `string` pattern of `^#?([A-Fa-f0-9]{3}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$` Color hex string, for example: #fff, #ffffff, or #ffffffff. * `integer` formatted as `uint8` | `integer` formatted as `uint8` | `integer` formatted as `uint8`\[] maximum of `3` items, minimum of `3` items Array of RGB colors. Each value has minimum of 0 and maximum of 255. * `integer` formatted as `uint8` | `integer` formatted as `uint8` | `integer` formatted as `uint8` | `integer` formatted as `uint8`\[] maximum of `4` items, minimum of `4` items Array of RGBA colors. Each value has minimum of 0 and maximum of 255. * Object of red, green, blue, alpha color values. Each value has minimum of 0 and maximum of 255. **Object Properties**: - alpha - blue (required) - green (required) - red (required) ##### alpha `integer` formatted as `uint8` **Default**: `255` ##### blue `integer` formatted as `uint8` ##### green `integer` formatted as `uint8` ##### red `integer` formatted as `uint8` ### Csp **Any of the following**: * `string` The entire CSP policy in a single text string. * An object mapping a directive with its sources values as a list of strings. **Allows additional properties**: [`CspDirectiveSources`](#cspdirectivesources) A Content-Security-Policy definition. See <>. ### CspDirectiveSources **Any of the following**: * `string` An inline list of CSP sources. Same as \[`Self::List`], but concatenated with a space separator. * `string`\[] A list of CSP sources. The collection will be concatenated with a space separator for the CSP string. A Content-Security-Policy directive source list. See <>. ### CustomSignCommandConfig **Any of the following**: * `string` A string notation of the script to execute. “%1” will be replaced with the path to the binary to be signed. This is a simpler notation for the command. Tauri will split the string with `' '` and use the first element as the command name and the rest as arguments. If you need to use whitespace in the command or arguments, use the object notation \[`Self::CommandWithOptions`]. * An object notation of the command. This is more complex notation for the command but this allows you to use whitespace in the command and arguments. **Object Properties**: - args (required) - cmd (required) ##### args `string`\[] The arguments to pass to the command. “%1” will be replaced with the path to the binary to be signed. ##### cmd `string` The command to run to sign the binary. Custom Signing Command configuration. ### DebConfig Configuration for Debian (.deb) bundles. See more: <> **Object Properties**: * changelog * conflicts * depends * desktopTemplate * files * postInstallScript * postRemoveScript * preInstallScript * preRemoveScript * priority * provides * recommends * replaces * section ##### changelog `string` | `null` Path of the uncompressed Changelog file, to be stored at /usr/share/doc/package-name/changelog.gz. See <> ##### conflicts `string`\[] | `null` The list of package conflicts. ##### depends `string`\[] | `null` The list of deb dependencies your application relies on. ##### desktopTemplate `string` | `null` Path to a custom desktop file Handlebars template. Available variables: `categories`, `comment` (optional), `exec`, `icon` and `name`. ##### files The files to include on the package. **Allows additional properties**: `string` **Default**: `{}` ##### postInstallScript `string` | `null` Path to script that will be executed after the package is unpacked. See <> ##### postRemoveScript `string` | `null` Path to script that will be executed after the package is removed. See <> ##### preInstallScript `string` | `null` Path to script that will be executed before the package is unpacked. See <> ##### preRemoveScript `string` | `null` Path to script that will be executed before the package is removed. See <> ##### priority `string` | `null` Change the priority of the Debian Package. By default, it is set to `optional`. Recognized Priorities as of now are : `required`, `important`, `standard`, `optional`, `extra` ##### provides `string`\[] | `null` The list of dependencies the package provides. ##### recommends `string`\[] | `null` The list of deb dependencies your application recommends. ##### replaces `string`\[] | `null` The list of package replaces. ##### section `string` | `null` Define the section in Debian Control file. See : ### DisabledCspModificationKind **Any of the following**: * `boolean` If `true`, disables all CSP modification. `false` is the default value and it configures Tauri to control the CSP. * `string`\[] Disables the given list of CSP directives modifications. The possible values for the `dangerous_disable_asset_csp_modification` config option. ### DmgConfig Configuration for Apple Disk Image (.dmg) bundles. See more: <> **Object Properties**: * applicationFolderPosition * appPosition * background * windowPosition * windowSize ##### applicationFolderPosition [`Position`](#position) Position of application folder on window. Default ```json { "x": 480, "y": 170 } ``` ##### appPosition [`Position`](#position) Position of app file on window. Default ```json { "x": 180, "y": 170 } ``` ##### background `string` | `null` Image to use as the background in dmg file. Accepted formats: `png`/`jpg`/`gif`. ##### windowPosition [`Position`](#position) | `null` Position of volume window on screen. ##### windowSize [`Size`](#size) Size of volume window. Default ```json { "height": 400, "width": 660 } ``` ### ExportedFileAssociation The exported type definition. Maps to a `UTExportedTypeDeclarations` entry on macOS. **Object Properties**: * conformsTo * identifier (required) ##### conformsTo `string`\[] | `null` The types that this type conforms to. Maps to `UTTypeConformsTo`. Examples are `public.data`, `public.image`, `public.json` and `public.database`. ##### identifier `string` The unique identifier for the exported type. Maps to `UTTypeIdentifier`. ### FileAssociation File association **Object Properties**: * androidIntentActionFilters * contentTypes * description * exportedType * ext (required) * mimeType * name * rank * role ##### androidIntentActionFilters [`AndroidIntentAction`](#androidintentaction)\[] | `null` Intent action filters for this file association. By default all filters are used. ##### contentTypes `string`\[] | `null` Declare support to a file with the given content type. Maps to `LSItemContentTypes` on macOS. This allows supporting any file format declared by another application that conforms to this type. Declaration of new types can be done with \[`Self::exported_type`] and linking to certain content types are done via \[`ExportedFileAssociation::conforms_to`]. ##### description `string` | `null` The association description. Windows-only. It is displayed on the `Type` column on Windows Explorer. ##### exportedType [`ExportedFileAssociation`](#exportedfileassociation) | `null` The exported type definition. Maps to a `UTExportedTypeDeclarations` entry on macOS. You should define this if the associated file is a custom file type defined by your application. ##### ext [`AssociationExt`](#associationext)\[] File extensions to associate with this app. e.g. ‘png’ ##### mimeType `string` | `null` The mime-type of the association, e.g. `'image/png'` or `'text/plain'`. * **Linux**: written as `MimeType=` in the `.desktop` file. * **macOS / iOS**: added as `public.mime-type` in the `UTTypeTagSpecification` dictionary of the `UTExportedTypeDeclarations` entry in `Info.plist`. * **Android**: used as `android:mimeType` in the `<data>` element of an `<intent-filter>` in `AndroidManifest.xml`. ##### name `string` | `null` The name. Maps to `CFBundleTypeName` on macOS. Default to `ext[0]` ##### rank [`HandlerRank`](#handlerrank) The ranking of this app among apps that declare themselves as editors or viewers of the given file type. Maps to `LSHandlerRank` on macOS. **Default**: `"Default"` ##### role [`BundleTypeRole`](#bundletyperole) The app’s role with respect to the type. Maps to `CFBundleTypeRole` on macOS. **Default**: `"Editor"` ### FrontendDist **Any of the following**: * `string` formatted as `uri` An external URL that should be used as the default application URL. No assets are embedded in the app in this case. * `string` Path to a directory containing the frontend dist assets. * `string`\[] An array of files to embed in the app. Defines the URL or assets to embed in the application. ### FsScope **Any of the following**: * `string`\[] A list of paths that are allowed by this scope. * A complete scope configuration. **Object Properties**: - allow - deny - requireLiteralLeadingDot ##### allow `string`\[] A list of paths that are allowed by this scope. **Default**: `[]` ##### deny `string`\[] A list of paths that are not allowed by this scope. This gets precedence over the \[`Self::Scope::allow`] list. **Default**: `[]` ##### requireLiteralLeadingDot `boolean` | `null` Whether or not paths that contain components that start with a `.` will require that `.` appears literally in the pattern; `*`, `?`, `**`, or `[...]` will not match. This is useful because such files are conventionally considered hidden on Unix systems and it might be desirable to skip them when listing files. Defaults to `true` on Unix systems and `false` on Windows Protocol scope definition. It is a list of glob patterns that restrict the API access from the webview. Each pattern can start with a variable that resolves to a system base directory. The variables are: `$AUDIO`, `$CACHE`, `$CONFIG`, `$DATA`, `$LOCALDATA`, `$DESKTOP`, `$DOCUMENT`, `$DOWNLOAD`, `$EXE`, `$FONT`, `$HOME`, `$PICTURE`, `$PUBLIC`, `$RUNTIME`, `$TEMPLATE`, `$VIDEO`, `$RESOURCE`, `$TEMP`, `$APPCONFIG`, `$APPDATA`, `$APPLOCALDATA`, `$APPCACHE`, `$APPLOG`. ### HandlerRank **One of the following**: * `"Default"` LSHandlerRank.Default. This app is an opener of files of this type; this value is also used if no rank is specified. * `"Owner"` LSHandlerRank.Owner. This app is the primary creator of files of this type. * `"Alternate"` LSHandlerRank.Alternate. This app is a secondary viewer of files of this type. * `"None"` LSHandlerRank.None. This app is never selected to open files of this type, but it accepts drops of files of this type. Corresponds to LSHandlerRank ### HeaderConfig A struct, where the keys are some specific http header names. If the values to those keys are defined, then they will be send as part of a response message. This does not include error messages and ipc messages ##### Example configuration ```javascript { //.. app:{ //.. security: { headers: { "Cross-Origin-Opener-Policy": "same-origin", "Cross-Origin-Embedder-Policy": "require-corp", "Timing-Allow-Origin": [ "https://developer.mozilla.org", "https://example.com", ], "Access-Control-Expose-Headers": "Tauri-Custom-Header", "Tauri-Custom-Header": { "key1": "'value1' 'value2'", "key2": "'value3'" } }, csp: "default-src 'self'; connect-src ipc: http://ipc.localhost", } //.. } //.. } ``` In this example `Cross-Origin-Opener-Policy` and `Cross-Origin-Embedder-Policy` are set to allow for the use of [`SharedArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer). The result is, that those headers are then set on every response sent via the `get_response` function in crates/tauri/src/protocol/tauri.rs. The Content-Security-Policy header is defined separately, because it is also handled separately. For the helloworld example, this config translates into those response headers: ```http access-control-allow-origin: http://tauri.localhost access-control-expose-headers: Tauri-Custom-Header content-security-policy: default-src 'self'; connect-src ipc: http://ipc.localhost; script-src 'self' 'sha256-Wjjrs6qinmnr+tOry8x8PPwI77eGpUFR3EEGZktjJNs=' content-type: text/html cross-origin-embedder-policy: require-corp cross-origin-opener-policy: same-origin tauri-custom-header: key1 'value1' 'value2'; key2 'value3' timing-allow-origin: https://developer.mozilla.org, https://example.com ``` Since the resulting header values are always ‘string-like’. So depending on the what data type the HeaderSource is, they need to be converted. * `String`(JS/Rust): stay the same for the resulting header value * `Array`(JS)/`Vec\<String\>`(Rust): Item are joined by “, “ for the resulting header value * `Object`(JS)/ `Hashmap\<String,String\>`(Rust): Items are composed from: key + space + value. Item are then joined by “; “ for the resulting header value **Object Properties**: * Access-Control-Allow-Credentials * Access-Control-Allow-Headers * Access-Control-Allow-Methods * Access-Control-Expose-Headers * Access-Control-Max-Age * Cross-Origin-Embedder-Policy * Cross-Origin-Opener-Policy * Cross-Origin-Resource-Policy * Permissions-Policy * Service-Worker-Allowed * Tauri-Custom-Header * Timing-Allow-Origin * X-Content-Type-Options ##### Access-Control-Allow-Credentials [`HeaderSource`](#headersource) | `null` The Access-Control-Allow-Credentials response header tells browsers whether the server allows cross-origin HTTP requests to include credentials. See <> ##### Access-Control-Allow-Headers [`HeaderSource`](#headersource) | `null` The Access-Control-Allow-Headers response header is used in response to a preflight request which includes the Access-Control-Request-Headers to indicate which HTTP headers can be used during the actual request. This header is required if the request has an Access-Control-Request-Headers header. See <> ##### Access-Control-Allow-Methods [`HeaderSource`](#headersource) | `null` The Access-Control-Allow-Methods response header specifies one or more methods allowed when accessing a resource in response to a preflight request. See <> ##### Access-Control-Expose-Headers [`HeaderSource`](#headersource) | `null` The Access-Control-Expose-Headers response header allows a server to indicate which response headers should be made available to scripts running in the browser, in response to a cross-origin request. See <> ##### Access-Control-Max-Age [`HeaderSource`](#headersource) | `null` The Access-Control-Max-Age response header indicates how long the results of a preflight request (that is the information contained in the Access-Control-Allow-Methods and Access-Control-Allow-Headers headers) can be cached. See <> ##### Cross-Origin-Embedder-Policy [`HeaderSource`](#headersource) | `null` The HTTP Cross-Origin-Embedder-Policy (COEP) response header configures embedding cross-origin resources into the document. See <> ##### Cross-Origin-Opener-Policy [`HeaderSource`](#headersource) | `null` The HTTP Cross-Origin-Opener-Policy (COOP) response header allows you to ensure a top-level document does not share a browsing context group with cross-origin documents. COOP will process-isolate your document and potential attackers can’t access your global object if they were to open it in a popup, preventing a set of cross-origin attacks dubbed XS-Leaks. See <> ##### Cross-Origin-Resource-Policy [`HeaderSource`](#headersource) | `null` The HTTP Cross-Origin-Resource-Policy response header conveys a desire that the browser blocks no-cors cross-origin/cross-site requests to the given resource. See <> ##### Permissions-Policy [`HeaderSource`](#headersource) | `null` The HTTP Permissions-Policy header provides a mechanism to allow and deny the use of browser features in a document or within any \<iframe\> elements in the document. See <> ##### Service-Worker-Allowed [`HeaderSource`](#headersource) | `null` The HTTP Service-Worker-Allowed response header is used to broaden the path restriction for a service worker’s default scope. By default, the scope for a service worker registration is the directory where the service worker script is located. For example, if the script `sw.js` is located in `/js/sw.js`, it can only control URLs under `/js/` by default. Servers can use the `Service-Worker-Allowed` header to allow a service worker to control URLs outside of its own directory. See <> ##### Tauri-Custom-Header [`HeaderSource`](#headersource) | `null` A custom header field Tauri-Custom-Header, don’t use it. Remember to set Access-Control-Expose-Headers accordingly **NOT INTENDED FOR PRODUCTION USE** ##### Timing-Allow-Origin [`HeaderSource`](#headersource) | `null` The Timing-Allow-Origin response header specifies origins that are allowed to see values of attributes retrieved via features of the Resource Timing API, which would otherwise be reported as zero due to cross-origin restrictions. See <> ##### X-Content-Type-Options [`HeaderSource`](#headersource) | `null` The X-Content-Type-Options response HTTP header is a marker used by the server to indicate that the MIME types advertised in the Content-Type headers should be followed and not be changed. The header allows you to avoid MIME type sniffing by saying that the MIME types are deliberately configured. See <> ### HeaderSource **Any of the following**: * `string` string version of the header Value * `string`\[] list version of the header value. Item are joined by “,” for the real header value * (Rust struct | Json | JavaScript Object) equivalent of the header value. Items are composed from: key + space + value. Item are then joined by “;” for the real header value **Allows additional properties**: `string` definition of a header source The header value to a header name ### HookCommand **Any of the following**: * `string` Run the given script with the default options. * Run the given script with custom options. **Object Properties**: - cwd - script (required) ##### cwd `string` | `null` The current working directory. ##### script `string` The script to execute. Describes a shell command to be executed when a CLI hook is triggered. ### Identifier `string` ### IosConfig General configuration for the iOS target. **Object Properties**: * bundleVersion * developmentTeam * frameworks * infoPlist * minimumSystemVersion * template ##### bundleVersion `string` | `null` The version of the build that identifies an iteration of the bundle. Translates to the bundle’s CFBundleVersion property. ##### developmentTeam `string` | `null` The development team. This value is required for iOS development because code signing is enforced. The `APPLE_DEVELOPMENT_TEAM` environment variable can be set to overwrite it. ##### frameworks `string`\[] | `null` A list of strings indicating any iOS frameworks that need to be bundled with the application. Note that you need to recreate the iOS project for the changes to be applied. ##### infoPlist `string` | `null` Path to a Info.plist file to merge with the default Info.plist. Note that Tauri also looks for a `Info.plist` and `Info.ios.plist` file in the same directory as the Tauri configuration file. ##### minimumSystemVersion `string` A version string indicating the minimum iOS version that the bundled application supports. Defaults to `13.0`. Maps to the IPHONEOS\_DEPLOYMENT\_TARGET value. **Default**: `"14.0"` ##### template `string` | `null` A custom [XcodeGen](%3Chttps://github.com/yonaskolb/XcodeGen%3E) project.yml template to use. ### LinuxConfig Configuration for Linux bundles. See more: <> **Object Properties**: * appimage * deb * rpm ##### appimage [`AppImageConfig`](#appimageconfig) Configuration for the AppImage bundle. Default ```json { "bundleMediaFramework": false, "files": {} } ``` ##### deb [`DebConfig`](#debconfig) Configuration for the Debian bundle. Default ```json { "files": {} } ``` ##### rpm [`RpmConfig`](#rpmconfig) Configuration for the RPM bundle. Default ```json { "epoch": 0, "files": {}, "release": "1" } ``` ### LogicalPosition Position coordinates struct. **Object Properties**: * x (required) * y (required) ##### x `number` formatted as `double` X coordinate. ##### y `number` formatted as `double` Y coordinate. ### MacConfig Configuration for the macOS bundles. See more: <> **Object Properties**: * bundleName * bundleVersion * dmg * entitlements * exceptionDomain * files * frameworks * hardenedRuntime * infoPlist * minimumSystemVersion * providerShortName * signingIdentity ##### bundleName `string` | `null` The name of the builder that built the bundle. Translates to the bundle’s CFBundleName property. If not set, defaults to the package’s product name. ##### bundleVersion `string` | `null` The version of the build that identifies an iteration of the bundle. Translates to the bundle’s CFBundleVersion property. ##### dmg [`DmgConfig`](#dmgconfig) DMG-specific settings. Default ```json { "appPosition": { "x": 180, "y": 170 }, "applicationFolderPosition": { "x": 480, "y": 170 }, "windowSize": { "height": 400, "width": 660 } } ``` ##### entitlements `string` | `null` Path to the entitlements file. ##### exceptionDomain `string` | `null` Allows your application to communicate with the outside world. It should be a lowercase, without port and protocol domain name. ##### files The files to include in the application relative to the Contents directory. **Allows additional properties**: `string` **Default**: `{}` ##### frameworks `string`\[] | `null` A list of strings indicating any macOS X frameworks that need to be bundled with the application. If a name is used, “.framework” must be omitted and it will look for standard install locations. You may also use a path to a specific framework. ##### hardenedRuntime `boolean` Whether the codesign should enable [hardened runtime](https://developer.apple.com/documentation/security/hardened_runtime) (for executables) or not. **Default**: `true` ##### infoPlist `string` | `null` Path to a Info.plist file to merge with the default Info.plist. Note that Tauri also looks for a `Info.plist` file in the same directory as the Tauri configuration file. ##### minimumSystemVersion `string` | `null` A version string indicating the minimum macOS X version that the bundled application supports. Defaults to `10.13`. Setting it to `null` completely removes the `LSMinimumSystemVersion` field on the bundle’s `Info.plist` and the `MACOSX_DEPLOYMENT_TARGET` environment variable. Ignored in `tauri dev`. An empty string is considered an invalid value so the default value is used. **Default**: `"10.13"` ##### providerShortName `string` | `null` Provider short name for notarization. ##### signingIdentity `string` | `null` Identity to use for code signing. ### NsisCompression **One of the following**: * `"zlib"` ZLIB uses the deflate algorithm, it is a quick and simple method. With the default compression level it uses about 300 KB of memory. * `"bzip2"` BZIP2 usually gives better compression ratios than ZLIB, but it is a bit slower and uses more memory. With the default compression level it uses about 4 MB of memory. * `"lzma"` LZMA (default) is a new compression method that gives very good compression ratios. The decompression speed is high (10-20 MB/s on a 2 GHz CPU), the compression speed is lower. The memory size that will be used for decompression is the dictionary size plus a few KBs, the default is 8 MB. * `"none"` Disable compression Compression algorithms used in the NSIS installer. See <> ### NsisConfig Configuration for the Installer bundle using NSIS. **Object Properties**: * compression * customLanguageFiles * displayLanguageSelector * headerImage * installerHooks * installerIcon * installMode * languages * minimumWebview2Version * sidebarImage * startMenuFolder * template * uninstallerHeaderImage * uninstallerIcon ##### compression [`NsisCompression`](#nsiscompression) Set the compression algorithm used to compress files in the installer. See <> **Default**: `"lzma"` ##### customLanguageFiles \| `null` A key-value pair where the key is the language and the value is the path to a custom `.nsh` file that holds the translated text for tauri’s custom messages. See <> for an example `.nsh` file. **Note**: the key must be a valid NSIS language and it must be added to the \[`Self::languages`] array, **Allows additional properties**: `string` ##### displayLanguageSelector `boolean` Whether to display a language selector dialog before the installer and uninstaller windows are rendered or not. By default the OS language is selected, with a fallback to the first language in the `languages` array. ##### headerImage `string` | `null` The path to a bitmap file to display on the header of installers pages. The recommended dimensions are 150px x 57px. ##### installerHooks `string` | `null` A path to a `.nsh` file that contains special NSIS macros to be hooked into the main installer.nsi script. Supported hooks are: * `NSIS_HOOK_PREINSTALL`: This hook runs before copying files, setting registry key values and creating shortcuts. * `NSIS_HOOK_POSTINSTALL`: This hook runs after the installer has finished copying all files, setting the registry keys and created shortcuts. * `NSIS_HOOK_PREUNINSTALL`: This hook runs before removing any files, registry keys and shortcuts. * `NSIS_HOOK_POSTUNINSTALL`: This hook runs after files, registry keys and shortcuts have been removed. ###### Example ```nsh !macro NSIS_HOOK_PREINSTALL MessageBox MB_OK "PreInstall" !macroend !macro NSIS_HOOK_POSTINSTALL MessageBox MB_OK "PostInstall" !macroend !macro NSIS_HOOK_PREUNINSTALL MessageBox MB_OK "PreUnInstall" !macroend !macro NSIS_HOOK_POSTUNINSTALL MessageBox MB_OK "PostUninstall" !macroend ``` ##### installerIcon `string` | `null` The path to an icon file used as the installer icon. ##### installMode [`NSISInstallerMode`](#nsisinstallermode) Whether the installation will be for all users or just the current user. **Default**: `"currentUser"` ##### languages `string`\[] | `null` A list of installer languages. Default to `["English"]` if not set. By default the OS language is used. If the OS language is not in the list of languages, the first language will be used. To allow the user to select the language, set `display_language_selector` to `true`. See <> for the complete list of languages. ##### minimumWebview2Version `string` | `null` Deprecated: use \[`WindowsConfig::minimum_webview2_version`] (`bundle > windows > minimumWebview2Version`) instead. Try to ensure that the WebView2 version is equal to or newer than this version, if the user’s WebView2 is older than this version, the installer will try to trigger a WebView2 update. ##### sidebarImage `string` | `null` The path to a bitmap file for the Welcome page and the Finish page. The recommended dimensions are 164px x 314px. ##### startMenuFolder `string` | `null` Set the folder name for the start menu shortcut. Use this option if you have multiple apps and wish to group their shortcuts under one folder or if you generally prefer to set your shortcut inside a folder. Examples: * `AwesomePublisher`, shortcut will be placed in `%AppData%\Microsoft\Windows\Start Menu\Programs\AwesomePublisher\<your-app>.lnk` * If unset, shortcut will be placed in `%AppData%\Microsoft\Windows\Start Menu\Programs\<your-app>.lnk` ##### template `string` | `null` A custom .nsi template to use. ##### uninstallerHeaderImage `string` | `null` The path to a bitmap file to display on the header of uninstallers pages. Defaults to \[`Self::header_image`]. If this is set but \[`Self::header_image`] is not, a default image from NSIS will be applied to `header_image` The recommended dimensions are 150px x 57px. ##### uninstallerIcon `string` | `null` The path to an icon file used as the uninstaller icon. ### NSISInstallerMode **One of the following**: * `"currentUser"` Default mode for the installer. Install the app by default in a directory that doesn’t require Administrator access. Installer metadata will be saved under the `HKCU` registry path. * `"perMachine"` Install the app by default in the `Program Files` folder directory requires Administrator access for the installation. Installer metadata will be saved under the `HKLM` registry path. * `"both"` Combines both modes and allows the user to choose at install time whether to install for the current user or per machine. Note that this mode will require Administrator access even if the user wants to install it for the current user only. Installer metadata will be saved under the `HKLM` or `HKCU` registry path based on the user’s choice. Install Modes for the NSIS installer. ### Number **Any of the following**: * `integer` formatted as `int64` Represents an \[`i64`]. * `number` formatted as `double` Represents a \[`f64`]. A valid ACL number. ### PatternKind **One of the following**: * Brownfield pattern. **Object Properties**: - use (required) ##### use `"brownfield"` * Isolation pattern. Recommended for security purposes. **Object Properties**: - options (required) - use (required) ##### options **Object Properties**: - dir (required) ###### dir `string` The dir containing the index.html file that contains the secure isolation application. ##### use `"isolation"` The application pattern. ### PermissionEntry **Any of the following**: * [`Identifier`](#identifier) Reference a permission or permission set by identifier. * Reference a permission or permission set by identifier and extends its scope. **Object Properties**: - allow - deny - identifier (required) ##### allow [`Value`](#value)\[] | `null` Data that defines what is allowed by the scope. ##### deny [`Value`](#value)\[] | `null` Data that defines what is denied by the scope. This should be prioritized by validation logic. ##### identifier [`Identifier`](#identifier) Identifier of the permission or permission set. An entry for a permission value in a \[`Capability`] can be either a raw permission \[`Identifier`] or an object that references a permission and extends its scope. ### PluginConfig The plugin configs holds a HashMap mapping a plugin name to its configuration object. See more: <> **Allows additional properties**: `true` ### Position Position coordinates struct. **Object Properties**: * x (required) * y (required) ##### x `integer` formatted as `uint32` X coordinate. ##### y `integer` formatted as `uint32` Y coordinate. ### PreventOverflowConfig **Any of the following**: * `boolean` Enable prevent overflow or not * [`PreventOverflowMargin`](#preventoverflowmargin) Enable prevent overflow with a margin so that the window’s size + this margin won’t overflow the workarea Prevent overflow with a margin ### PreventOverflowMargin Enable prevent overflow with a margin so that the window’s size + this margin won’t overflow the workarea **Object Properties**: * height (required) * width (required) ##### height `integer` formatted as `uint32` Vertical margin in physical pixels ##### width `integer` formatted as `uint32` Horizontal margin in physical pixels ### RpmCompression **One of the following**: * Gzip compression **Object Properties**: - level (required) - type (required) ##### level `integer` formatted as `uint32` Gzip compression level ##### type `"gzip"` * Zstd compression **Object Properties**: - level (required) - type (required) ##### level `integer` formatted as `int32` Zstd compression level ##### type `"zstd"` * Xz compression **Object Properties**: - level (required) - type (required) ##### level `integer` formatted as `uint32` Xz compression level ##### type `"xz"` * Bzip2 compression **Object Properties**: - level (required) - type (required) ##### level `integer` formatted as `uint32` Bzip2 compression level ##### type `"bzip2"` * Disable compression **Object Properties**: - type (required) ##### type `"none"` Compression algorithms used when bundling RPM packages. ### RpmConfig Configuration for RPM bundles. **Object Properties**: * compression * conflicts * depends * desktopTemplate * epoch * files * obsoletes * postInstallScript * postRemoveScript * preInstallScript * preRemoveScript * provides * recommends * release ##### compression [`RpmCompression`](#rpmcompression) | `null` Compression algorithm and level. Defaults to `Gzip` with level 6. ##### conflicts `string`\[] | `null` The list of RPM dependencies your application conflicts with. They must not be present in order for the package to be installed. ##### depends `string`\[] | `null` The list of RPM dependencies your application relies on. ##### desktopTemplate `string` | `null` Path to a custom desktop file Handlebars template. Available variables: `categories`, `comment` (optional), `exec`, `icon` and `name`. ##### epoch `integer` formatted as `uint32` The RPM epoch. ##### files The files to include on the package. **Allows additional properties**: `string` **Default**: `{}` ##### obsoletes `string`\[] | `null` The list of RPM dependencies your application supersedes - if this package is installed, packages listed as “obsoletes” will be automatically removed (if they are present). ##### postInstallScript `string` | `null` Path to script that will be executed after the package is unpacked. See <> ##### postRemoveScript `string` | `null` Path to script that will be executed after the package is removed. See <> ##### preInstallScript `string` | `null` Path to script that will be executed before the package is unpacked. See <> ##### preRemoveScript `string` | `null` Path to script that will be executed before the package is removed. See <> ##### provides `string`\[] | `null` The list of RPM dependencies your application provides. ##### recommends `string`\[] | `null` The list of RPM dependencies your application recommends. ##### release `string` The RPM release tag. **Default**: `"1"` ### RunnerConfig **Any of the following**: * `string` A string specifying the binary to run. * An object with advanced configuration options. **Object Properties**: - args - cmd (required) - cwd ##### args `string`\[] | `null` Arguments to pass to the command. ##### cmd `string` The binary to run. ##### cwd `string` | `null` The current working directory to run the command from. The runner configuration. ### ScrollBarStyle **One of the following**: * `"default"` The scrollbar style to use in the webview. * `"fluentOverlay"` Fluent UI style overlay scrollbars. **Windows Only** Requires WebView2 Runtime version 125.0.2535.41 or higher, does nothing on older versions, see <> The scrollbar style to use in the webview. ##### Platform-specific * **Windows**: This option must be given the same value for all webviews that target the same data directory. ### SecurityConfig Security configuration. See more: <> **Object Properties**: * assetProtocol * capabilities * csp * dangerousDisableAssetCspModification * devCsp * freezePrototype * headers * pattern ##### assetProtocol [`AssetProtocolConfig`](#assetprotocolconfig) Custom protocol config. Default ```json { "enable": false, "scope": [] } ``` ##### capabilities [`CapabilityEntry`](#capabilityentry)\[] List of capabilities that are enabled on the application. By default (not set or empty list), all capability files from `./capabilities/` are included, by setting values in this entry, you have fine grained control over which capabilities are included You can either reference a capability file defined in `./capabilities/` with its identifier or inline a \[`Capability`] ###### Example ```json { "app": { "capabilities": [ "main-window", { "identifier": "drag-window", "permissions": ["core:window:allow-start-dragging"] } ] } } ``` **Default**: `[]` ##### csp [`Csp`](#csp) | `null` The Content Security Policy that will be injected on all HTML files on the built application. If [`dev_csp`](#securityconfig) is not specified, this value is also injected on dev. This is a really important part of the configuration since it helps you ensure your WebView is secured. See <>. ##### dangerousDisableAssetCspModification [`DisabledCspModificationKind`](#disabledcspmodificationkind) Disables the Tauri-injected CSP sources. At compile time, Tauri parses all the frontend assets and changes the Content-Security-Policy to only allow loading of your own scripts and styles by injecting nonce and hash sources. This stricts your CSP, which may introduce issues when using along with other flexing sources. This configuration option allows both a boolean and a list of strings as value. A boolean instructs Tauri to disable the injection for all CSP injections, and a list of strings indicates the CSP directives that Tauri cannot inject. **WARNING:** Only disable this if you know what you are doing and have properly configured the CSP. Your application might be vulnerable to XSS attacks without this Tauri protection. ##### devCsp [`Csp`](#csp) | `null` The Content Security Policy that will be injected on all HTML files on development. This is a really important part of the configuration since it helps you ensure your WebView is secured. See <>. ##### freezePrototype `boolean` Freeze the `Object.prototype` when using the custom protocol. ##### headers [`HeaderConfig`](#headerconfig) | `null` The headers, which are added to every http response from tauri to the web view This doesn’t include IPC Messages and error responses ##### pattern [`PatternKind`](#patternkind) The pattern to use. Default ```json { "use": "brownfield" } ``` ### Size Size of the window. **Object Properties**: * height (required) * width (required) ##### height `integer` formatted as `uint32` Height of the window. ##### width `integer` formatted as `uint32` Width of the window. ### Target **One of the following**: * `"macOS"` MacOS. * `"windows"` Windows. * `"linux"` Linux. * `"android"` Android. * `"iOS"` iOS. Platform target. ### Theme **One of the following**: * `"Light"` Light theme. * `"Dark"` Dark theme. System theme. ### TitleBarStyle **One of the following**: * `"Visible"` A normal title bar. * `"Transparent"` Makes the title bar transparent, so the window background color is shown instead. Useful if you don’t need to have actual HTML under the title bar. This lets you avoid the caveats of using `TitleBarStyle::Overlay`. Will be more useful when Tauri lets you set a custom window background color. * `"Overlay"` Shows the title bar as a transparent overlay over the window’s content. Keep in mind: - The height of the title bar is different on different OS versions, which can lead to window the controls and title not being where you don’t expect. - You need to define a custom drag region to make your window draggable, however due to a limitation you can’t drag the window when it’s not in focus <>. - The color of the window title depends on the system theme. How the window title bar should be displayed on macOS. ### TrayIconConfig Configuration for application tray icon. See more: <> **Object Properties**: * iconAsTemplate * iconPath (required) * id * menuOnLeftClick * showMenuOnLeftClick * title * tooltip ##### iconAsTemplate `boolean` A Boolean value that determines whether the image represents a [template](https://developer.apple.com/documentation/appkit/nsimage/1520017-template?language=objc) image on macOS. ##### iconPath `string` Path to the default icon to use for the tray icon. Note: this stores the image in raw pixels to the final binary, so keep the icon size (width and height) small or else it’s going to bloat your final executable ##### id `string` | `null` Set an id for this tray icon so you can reference it later, defaults to `main`. ##### menuOnLeftClick `boolean` **No longer works since v2.2, use \[`Self::show_menu_on_left_click`] instead** A Boolean value that determines whether the menu should appear when the tray icon receives a left click. ###### Platform-specific: * **Linux**: Unsupported. **Default**: `true` ##### showMenuOnLeftClick `boolean` A Boolean value that determines whether the menu should appear when the tray icon receives a left click. ###### Platform-specific: * **Linux**: Unsupported. **Default**: `true` ##### title `string` | `null` Title for MacOS tray ##### tooltip `string` | `null` Tray icon tooltip on Windows and macOS ### Updater **Any of the following**: * [`V1Compatible`](#v1compatible) Generates legacy zipped v1 compatible updaters * `boolean` Produce updaters and their signatures or not Updater type ### V1Compatible `"v1Compatible"`,Generates legacy zipped v1 compatible updaters Generates legacy zipped v1 compatible updaters ### Value **Any of the following**: * `null` Represents a null JSON value. * `boolean` Represents a \[`bool`]. * [`Number`](#number) Represents a valid ACL \[`Number`]. * `string` Represents a \[`String`]. * [`Value`](#value)\[] Represents a list of other \[`Value`]s. * Represents a map of \[`String`] keys to \[`Value`]s. **Allows additional properties**: [`Value`](#value) All supported ACL values. ### WebviewInstallMode **One of the following**: * Do not install the Webview2 as part of the Windows Installer. **Object Properties**: - type (required) ##### type `"skip"` * Download the bootstrapper and run it. Requires an internet connection. Results in a smaller installer size, but is not recommended on Windows 7. **Object Properties**: - silent - type (required) ##### silent `boolean` Instructs the installer to run the bootstrapper in silent mode. Defaults to `true`. **Default**: `true` ##### type `"downloadBootstrapper"` * Embed the bootstrapper and run it. Requires an internet connection. Increases the installer size by around 1.8MB, but offers better support on Windows 7. **Object Properties**: - silent - type (required) ##### silent `boolean` Instructs the installer to run the bootstrapper in silent mode. Defaults to `true`. **Default**: `true` ##### type `"embedBootstrapper"` * Embed the offline installer and run it. Does not require an internet connection. Increases the installer size by around 127MB. **Object Properties**: - silent - type (required) ##### silent `boolean` Instructs the installer to run the installer in silent mode. Defaults to `true`. **Default**: `true` ##### type `"offlineInstaller"` * Embed a fixed webview2 version and use it at runtime. Increases the installer size by around 180MB. **Object Properties**: - path (required) - type (required) ##### path `string` The path to the fixed runtime to use. The fixed version can be downloaded [on the official website](https://developer.microsoft.com/en-us/microsoft-edge/webview2/#download-section). The `.cab` file must be extracted to a folder and this folder path must be defined on this field. ##### type `"fixedRuntime"` Install modes for the Webview2 runtime. Note that for the updater bundle \[`Self::DownloadBootstrapper`] is used. For more information see <>. ### WebviewUrl **Any of the following**: * `string` formatted as `uri` An external URL. Must use either the `http` or `https` schemes. * `string` The path portion of an app URL. For instance, to load `tauri://localhost/users/john`, you can simply provide `users/john` in this configuration. * `string` formatted as `uri` A custom protocol url, for example, `doom://index.html` An URL to open on a Tauri webview window. ### WindowConfig The window configuration object. See more: <> **Object Properties**: * acceptFirstMouse * activityName * additionalBrowserArgs * allowLinkPreview * alwaysOnBottom * alwaysOnTop * backgroundColor * backgroundThrottling * browserExtensionsEnabled * center * closable * contentProtected * create * createdByActivityName * dataDirectory * dataStoreIdentifier * decorations * devtools * disableInputAccessoryView * dragDropEnabled * focus * focusable * fullscreen * generalAutofillEnabled * height * hiddenTitle * incognito * javascriptDisabled * label * limitNavigationsToAppBoundDomains * maxHeight * maximizable * maximized * maxWidth * minHeight * minimizable * minWidth * noRedirectionBitmap * parent * preventOverflow * proxyUrl * requestedBySceneIdentifier * resizable * scrollBarStyle * shadow * skipTaskbar * tabbingIdentifier * theme * title * titleBarStyle * trafficLightPosition * transparent * url * useHttpsScheme * userAgent * visible * visibleOnAllWorkspaces * width * windowClassname * windowEffects * x * y * zoomHotkeysEnabled ##### acceptFirstMouse `boolean` Whether clicking an inactive window also clicks through to the webview on macOS. ##### activityName `string` | `null` The name of the Android activity to create for this window. ##### additionalBrowserArgs `string` | `null` Defines additional browser arguments on Windows. ###### Warning Webview instances with different browser arguments must also have different [data directories](Self::data_directory). By default wry passes `--disable-features=msWebOOUI,msPdfOOUI,msSmartScreenProtection` so if you set this, you also need to disable these components by yourself if you want. ##### allowLinkPreview `boolean` on macOS and iOS there is a link preview on long pressing links, this is enabled by default. see **Default**: `true` ##### alwaysOnBottom `boolean` Whether the window should always be below other windows. ##### alwaysOnTop `boolean` Whether the window should always be on top of other windows. ##### backgroundColor [`Color`](#color) | `null` Set the window and webview background color. ###### Platform-specific: * **Windows**: alpha channel is ignored for the window layer. * **Windows**: On Windows 7, alpha channel is ignored for the webview layer. * **Windows**: On Windows 8 and newer, if alpha channel is not `0`, it will be ignored for the webview layer. ##### backgroundThrottling [`BackgroundThrottlingPolicy`](#backgroundthrottlingpolicy) | `null` Change the default background throttling behaviour. By default, browsers use a suspend policy that will throttle timers and even unload the whole tab (view) to free resources after roughly 5 minutes when a view became minimized or hidden. This will pause all tasks until the documents visibility state changes back from hidden to visible by bringing the view back to the foreground. ###### Platform-specific * **Linux / Windows / Android**: Unsupported. Workarounds like a pending WebLock transaction might suffice. * **iOS**: Supported since version 17.0+. * **macOS**: Supported since version 14.0+. see <> ##### browserExtensionsEnabled `boolean` Whether browser extensions can be installed for the webview process ###### Platform-specific: * **Windows**: Enables the WebView2 environment’s [`AreBrowserExtensionsEnabled`](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2environmentoptions?view=webview2-winrt-1.0.2739.15#arebrowserextensionsenabled) * **MacOS / Linux / iOS / Android** - Unsupported. ##### center `boolean` Whether or not the window starts centered or not. ##### closable `boolean` Whether the window’s native close button is enabled or not. ###### Platform-specific * **Linux:** “GTK+ will do its best to convince the window manager not to show a close button. Depending on the system, this function may not have any effect when called on a window that is already visible” * **iOS / Android:** Unsupported. **Default**: `true` ##### contentProtected `boolean` Prevents the window contents from being captured by other apps. ##### create `boolean` Whether Tauri should create this window at app startup or not. When this is set to `false` you must manually grab the config object via `app.config().app.windows` and create it with [`WebviewWindowBuilder::from_config`](https://docs.rs/tauri/2/tauri/webview/struct.WebviewWindowBuilder.html#method.from_config). ###### Example: ```rust tauri::Builder::default() .setup(|app| { tauri::WebviewWindowBuilder::from_config(app.handle(), &app.config().app.windows[0])?.build()?; Ok(()) }); ``` **Default**: `true` ##### createdByActivityName `string` | `null` The name of the Android activity that is creating this webview window. This is important to determine which stack the activity will belong to. ##### dataDirectory `string` | `null` Set a custom path for the webview’s data directory (localStorage, cache, etc.) **relative to \[`appDataDir()`]/${label}**. To set absolute paths, use [`WebviewWindowBuilder::data_directory`](https://docs.rs/tauri/2/tauri/webview/struct.WebviewWindowBuilder.html#method.data_directory) ###### Platform-specific: * **Windows**: WebViews with different values for settings like `additionalBrowserArgs`, `browserExtensionsEnabled` or `scrollBarStyle` must have different data directories. * **macOS / iOS**: Unsupported, use `dataStoreIdentifier` instead. * **Android**: Unsupported. ##### dataStoreIdentifier `integer` formatted as `uint8`\[] | `null` maximum of `16` items, minimum of `16` items Initialize the WebView with a custom data store identifier. This can be seen as a replacement for `dataDirectory` which is unavailable in WKWebView. See The array must contain 16 u8 numbers. ###### Platform-specific: * **iOS**: Supported since version 17.0+. * **macOS**: Supported since version 14.0+. * **Windows / Linux / Android**: Unsupported. ##### decorations `boolean` Whether the window should have borders and bars. **Default**: `true` ##### devtools `boolean` | `null` Enable web inspector which is usually called browser devtools. Enabled by default. This API works in **debug** builds, but requires `devtools` feature flag to enable it in **release** builds. ###### Platform-specific * macOS: This will call private functions on **macOS**. * Android: Open `chrome://inspect/#devices` in Chrome to get the devtools window. Wry’s `WebView` devtools API isn’t supported on Android. * iOS: Open Safari > Develop > \[Your Device Name] > \[Your WebView] to get the devtools window. ##### disableInputAccessoryView `boolean` Allows disabling the input accessory view on iOS. The accessory view is the view that appears above the keyboard when a text input element is focused. It usually displays a view with “Done”, “Next” buttons. ##### dragDropEnabled `boolean` Whether the drag and drop handlers used internally to generate [`DragDropEvent`](https://docs.rs/tauri/latest/tauri/enum.DragDropEvent.html)s are enabled on the webview. By default it is enabled. Disabling it is required to use HTML5 drag and drop on the frontend on Windows since we replace the drag drop handler of WebView2. Note: this setting maps to [`WebviewBuilder::disable_drag_drop_handler`](https://docs.rs/tauri/latest/tauri/webview/struct.WebviewBuilder.html#method.disable_drag_drop_handler), not [`WindowBuilder::drag_and_drop`](https://docs.rs/tauri/latest/x86_64-pc-windows-msvc/tauri/window/struct.WindowBuilder.html#method.drag_and_drop). **Default**: `true` ##### focus `boolean` Whether the window will be initially focused or not. **Default**: `true` ##### focusable `boolean` Whether the window will be focusable or not. **Default**: `true` ##### fullscreen `boolean` Whether the window starts as fullscreen or not. ##### generalAutofillEnabled `boolean` Controls the WebView’s browser-level general autofill behavior. **This option does not disable password or credit card autofill.** When set to `false`, the WebView will not automatically populate general form fields using previously stored data such as addresses or contact information. If not specified, this is `true` by default. ###### Platform-specific * **Windows**: Supported. WebView2’s autofill feature (called “Suggestions”) may not honor `autocomplete="off"` on input elements in some cases. * **Linux / Android / iOS / macOS**: Unsupported and performs no operation. **Default**: `true` ##### height `number` formatted as `double` The window height in logical pixels. **Default**: `600` ##### hiddenTitle `boolean` If `true`, sets the window title to be hidden on macOS. ##### incognito `boolean` Whether or not the webview should be launched in incognito mode. ###### Platform-specific: * **Android**: Unsupported. ##### javascriptDisabled `boolean` Whether we should disable JavaScript code execution on the webview or not. ##### label `string` The window identifier. It must be alphanumeric. **Default**: `"main"` ##### limitNavigationsToAppBoundDomains `boolean` Whether to limit navigations to App-Bound Domains. This is necessary to enable Service Workers on iOS according to [StackOverflow](https://stackoverflow.com/questions/49673399/service-workers-unavailable-in-wkwebview-in-ios-11-3/64155509#64155509). Default is false. Note: If you set this to `true` make sure to add localhost and any [`registrable domains`](https://developer.mozilla.org/en-US/docs/Glossary/Registrable_domain) used in this webview to tauri-src/Info.ios.plist: ```xml <plist> <dict> <key>WKAppBoundDomains</key> <array> <string>localhost</string> <string>aregistrabledomain.example</string> </array> </dict> </plist> ``` You must add `localhost` if any webview with this set to true opens a local webpage, makes any localhost calls, or uses the isolation pattern because Tauri uses the `localhost` domain for hosting the application webpage, the IPC protocol, and the isolation pattern’s iframe. Requests served through custom uri schemes are allowed so long as they use a registrable domain specified in the `WKAppBoundDomains` array for all the requests from the app, including requests for the `localhost` domain. In theory, you can whitelist an entire uri scheme by including the protocol name followed by a colon. For example, to allow all requests using a custom “stream” uri scheme (see [this tauri example](https://github.com/tauri-apps/tauri/blob/dev/examples/streaming/main.rs)), you could add `stream:` to the AppBoundDomains array. That said, I’m not sure whether Apple would let your app through app review if you do whitelist an entire protocol because this feature is not mentioned in [their blog post on App-Bound Domains](https://webkit.org/blog/10882/app-bound-domains/). See and for the official documentation on App-Bound Domains. ###### Platform-specific * **iOS**: Supported since version 14.0+. * **Linux / Windows / Android / MacOS:** Unsupported. ##### maxHeight `number` | `null` formatted as `double` The max window height in logical pixels. ##### maximizable `boolean` Whether the window’s native maximize button is enabled or not. If resizable is set to false, this setting is ignored. ###### Platform-specific * **macOS:** Disables the “zoom” button in the window titlebar, which is also used to enter fullscreen mode. * **Linux / iOS / Android:** Unsupported. **Default**: `true` ##### maximized `boolean` Whether the window is maximized or not. ##### maxWidth `number` | `null` formatted as `double` The max window width in logical pixels. ##### minHeight `number` | `null` formatted as `double` The min window height in logical pixels. ##### minimizable `boolean` Whether the window’s native minimize button is enabled or not. ###### Platform-specific * **Linux / iOS / Android:** Unsupported. **Default**: `true` ##### minWidth `number` | `null` formatted as `double` The min window width in logical pixels. ##### noRedirectionBitmap `boolean` This sets `WS_EX_NOREDIRECTIONBITMAP`. This can avoid the white flash that may appear before the webview content is rendered when using a transparent window. **Windows only**. ##### parent `string` | `null` Sets the window associated with this label to be the parent of the window to be created. ###### Platform-specific * **Windows**: This sets the passed parent as an owner window to the window to be created. From [MSDN owned windows docs](https://docs.microsoft.com/en-us/windows/win32/winmsg/window-features#owned-windows): * An owned window is always above its owner in the z-order. * The system automatically destroys an owned window when its owner is destroyed. * An owned window is hidden when its owner is minimized. * **Linux**: This makes the new window transient for parent, see <> * **macOS**: This adds the window as a child of parent, see <> ##### preventOverflow [`PreventOverflowConfig`](#preventoverflowconfig) | `null` Whether or not to prevent the window from overflowing the workarea ###### Platform-specific * **iOS / Android:** Unsupported. ##### proxyUrl `string` | `null` formatted as `uri` The proxy URL for the WebView for all network requests. Must be either a `http://` or a `socks5://` URL. ###### Platform-specific * **macOS**: Requires the `macos-proxy` feature flag and only compiles for macOS 14+. ##### requestedBySceneIdentifier `string` | `null` Sets the identifier of the scene that is requesting the new scene, establishing a relationship between the two scenes. By default the system uses the foreground scene. ##### resizable `boolean` Whether the window is resizable or not. When resizable is set to false, native window’s maximize button is automatically disabled. **Default**: `true` ##### scrollBarStyle [`ScrollBarStyle`](#scrollbarstyle) Specifies the native scrollbar style to use with the webview. CSS styles that modify the scrollbar are applied on top of the native appearance configured here. Defaults to `default`, which is the browser default. ###### Platform-specific * **Windows**: * `fluentOverlay` requires WebView2 Runtime version 125.0.2535.41 or higher, and does nothing on older versions. * This option must be given the same value for all webviews that target the same data directory. * **Linux / Android / iOS / macOS**: Unsupported. Only supports `Default` and performs no operation. **Default**: `"default"` ##### shadow `boolean` Whether or not the window has shadow. ###### Platform-specific * **Windows:** * `false` has no effect on decorated window, shadow are always ON. * `true` will make undecorated window have a 1px white border, and on Windows 11, it will have a rounded corners. * **Linux:** Unsupported. **Default**: `true` ##### skipTaskbar `boolean` If `true`, hides the window icon from the taskbar on Windows and Linux. ##### tabbingIdentifier `string` | `null` Defines the window [tabbing identifier](%3Chttps://developer.apple.com/documentation/appkit/nswindow/1644704-tabbingidentifier%3E) for macOS. Windows with matching tabbing identifiers will be grouped together. If the tabbing identifier is not set, automatic tabbing will be disabled. ##### theme [`Theme`](#theme) | `null` The initial window theme. Defaults to the system theme. Only implemented on Windows and macOS 10.14+. ##### title `string` The window title. **Default**: `"Tauri App"` ##### titleBarStyle [`TitleBarStyle`](#titlebarstyle) The style of the macOS title bar. **Default**: `"Visible"` ##### trafficLightPosition [`LogicalPosition`](#logicalposition) | `null` The position of the window controls on macOS. Requires titleBarStyle: Overlay and decorations: true. ##### transparent `boolean` Whether the window is transparent or not. Note that on `macOS` this requires the `macos-private-api` feature flag, enabled under `tauri > macOSPrivateApi`. WARNING: Using private APIs on `macOS` prevents your application from being accepted to the `App Store`. On Windows, using `noRedirectionBitmap` can help avoid a white flash when creating a transparent window. ##### url [`WebviewUrl`](#webviewurl) The window webview URL. **Default**: `"index.html"` ##### useHttpsScheme `boolean` Sets whether the custom protocols should use `https://<scheme>.localhost` instead of the default `http://<scheme>.localhost` on Windows and Android. Defaults to `false`. ###### Note Using a `https` scheme will NOT allow mixed content when trying to fetch `http` endpoints and therefore will not match the behavior of the `<scheme>://localhost` protocols used on macOS and Linux. ###### Warning Changing this value between releases will change the IndexedDB, cookies and localstorage location and your app will not be able to access the old data. ##### userAgent `string` | `null` The user agent for the webview ##### visible `boolean` Whether the window is visible or not. **Default**: `true` ##### visibleOnAllWorkspaces `boolean` Whether the window should be visible on all workspaces or virtual desktops. ###### Platform-specific * **Windows / iOS / Android:** Unsupported. ##### width `number` formatted as `double` The window width in logical pixels. **Default**: `800` ##### windowClassname `string` | `null` The name of the window class created on Windows to create the window. **Windows only**. ##### windowEffects [`WindowEffectsConfig`](#windoweffectsconfig) | `null` Window effects. Requires the window to be transparent. ###### Platform-specific: * **Windows**: If using decorations or shadows, you may want to try this workaround <> * **Linux**: Unsupported ##### x `number` | `null` formatted as `double` The horizontal position of the window’s top left corner in logical pixels ##### y `number` | `null` formatted as `double` The vertical position of the window’s top left corner in logical pixels ##### zoomHotkeysEnabled `boolean` Whether page zooming by hotkeys is enabled ###### Platform-specific: * **Windows**: Controls WebView2’s [`IsZoomControlEnabled`](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2settings?view=webview2-winrt-1.0.2420.47#iszoomcontrolenabled) setting. * **MacOS / Linux**: Injects a polyfill that zooms in and out with `ctrl/command` + `-/=`, 20% in each step, ranging from 20% to 1000%. Requires `webview:allow-set-webview-zoom` permission * **Android / iOS**: Unsupported. ### WindowEffect **One of the following**: * `"appearanceBased"` A default material appropriate for the view’s effectiveAppearance. **macOS 10.14-** * `"light"` **macOS 10.14-** * `"dark"` **macOS 10.14-** * `"mediumLight"` **macOS 10.14-** * `"ultraDark"` **macOS 10.14-** * `"titlebar"` **macOS 10.10+** * `"selection"` **macOS 10.10+** * `"menu"` **macOS 10.11+** * `"popover"` **macOS 10.11+** * `"sidebar"` **macOS 10.11+** * `"headerView"` **macOS 10.14+** * `"sheet"` **macOS 10.14+** * `"windowBackground"` **macOS 10.14+** * `"hudWindow"` **macOS 10.14+** * `"fullScreenUI"` **macOS 10.14+** * `"tooltip"` **macOS 10.14+** * `"contentBackground"` **macOS 10.14+** * `"underWindowBackground"` **macOS 10.14+** * `"underPageBackground"` **macOS 10.14+** * `"mica"` Mica effect that matches the system dark preference **Windows 11 Only** * `"micaDark"` Mica effect with dark mode but only if dark mode is enabled on the system **Windows 11 Only** * `"micaLight"` Mica effect with light mode **Windows 11 Only** * `"tabbed"` Tabbed effect that matches the system dark preference **Windows 11 Only** * `"tabbedDark"` Tabbed effect with dark mode but only if dark mode is enabled on the system **Windows 11 Only** * `"tabbedLight"` Tabbed effect with light mode **Windows 11 Only** * `"blur"` **Windows 7/10/11(22H1) Only** ##### Notes This effect has bad performance when resizing/dragging the window on Windows 11 build 22621. * `"acrylic"` **Windows 10/11 Only** ##### Notes This effect has bad performance when resizing/dragging the window on Windows 10 v1903+ and Windows 11 build 22000. Platform-specific window effects ### WindowEffectsConfig The window effects configuration object **Object Properties**: * color * effects (required) * radius * state ##### color [`Color`](#color) | `null` Window effect color. Affects \[`WindowEffect::Blur`] and \[`WindowEffect::Acrylic`] only on Windows 10 v1903+. Doesn’t have any effect on Windows 7 or Windows 11. ##### effects [`WindowEffect`](#windoweffect)\[] List of Window effects to apply to the Window. Conflicting effects will apply the first one and ignore the rest. ##### radius `number` | `null` formatted as `double` Window effect corner radius **macOS Only** ##### state [`WindowEffectState`](#windoweffectstate) | `null` Window effect state **macOS Only** ### WindowEffectState **One of the following**: * `"followsWindowActiveState"` Make window effect state follow the window’s active state * `"active"` Make window effect state always active * `"inactive"` Make window effect state always inactive Window effect state **macOS only** <> ### WindowsBuildConfig Windows-specific build configuration. **Object Properties**: * staticVCRuntime ##### staticVCRuntime `boolean` Whether to statically link the Visual C++ runtime into the application binary on Windows MSVC targets. **Default**: `true` ### WindowsConfig Windows bundler configuration. See more: <> **Object Properties**: * allowDowngrades * bundleVCRuntime * certificateThumbprint * digestAlgorithm * minimumWebview2Version * nsis * signCommand * timestampUrl * tsp * webviewInstallMode * wix ##### allowDowngrades `boolean` Validates a second app installation, blocking the user from installing an older version if set to `false`. For instance, if `1.2.1` is installed, the user won’t be able to install app version `1.2.0` or `1.1.5`. The default value of this flag is `true`. **Default**: `true` ##### bundleVCRuntime `boolean` Whether to bundle the Visual C++ runtime DLLs alongside the application. This can be particularly useful when your application includes sidecars or DLLs that do not statically link the Visual C++ runtime and require the runtime DLLs at runtime, and you do not want to require users to install the Visual C++ Redistributable. This can also be useful when `build > windows > staticVCRuntime` is set to `false`. ##### certificateThumbprint `string` | `null` Specifies the SHA1 hash of the signing certificate. ##### digestAlgorithm `string` | `null` Specifies the file digest algorithm to use for creating file signatures. Required for code signing. SHA-256 is recommended. ##### minimumWebview2Version `string` | `null` Try to ensure that the WebView2 version is equal to or newer than this version, if the user’s WebView2 is older than this version, the installer will try to trigger a WebView2 update. ##### nsis [`NsisConfig`](#nsisconfig) | `null` Configuration for the installer generated with NSIS. ##### signCommand [`CustomSignCommandConfig`](#customsigncommandconfig) | `null` Specify a custom command to sign the binaries. This command needs to have a `%1` in args which is just a placeholder for the binary path, which we will detect and replace before calling the command. By Default we use `signtool.exe` which can be found only on Windows so if you are on another platform and want to cross-compile and sign you will need to use another tool like `osslsigncode`. ##### timestampUrl `string` | `null` Server to use during timestamping. ##### tsp `boolean` Whether to use Time-Stamp Protocol (TSP, a.k.a. RFC 3161) for the timestamp server. Your code signing provider may use a TSP timestamp server, like e.g. SSL.com does. If so, enable TSP by setting to true. ##### webviewInstallMode [`WebviewInstallMode`](#webviewinstallmode) The installation mode for the Webview2 runtime. Default ```json { "silent": true, "type": "downloadBootstrapper" } ``` ##### wix [`WixConfig`](#wixconfig) | `null` Configuration for the MSI generated with WiX. ### WixConfig Configuration for the MSI bundle using WiX. See more: <> **Object Properties**: * bannerPath * componentGroupRefs * componentRefs * dialogImagePath * enableElevatedUpdateTask * featureGroupRefs * featureRefs * fipsCompliant * fragmentPaths * language * mergeRefs * template * upgradeCode * version ##### bannerPath `string` | `null` Path to a bitmap file to use as the installation user interface banner. This bitmap will appear at the top of all but the first page of the installer. The required dimensions are 493px × 58px. ##### componentGroupRefs `string`\[] The ComponentGroup element ids you want to reference from the fragments. **Default**: `[]` ##### componentRefs `string`\[] The Component element ids you want to reference from the fragments. **Default**: `[]` ##### dialogImagePath `string` | `null` Path to a bitmap file to use on the installation user interface dialogs. It is used on the welcome and completion dialogs. The required dimensions are 493px × 312px. ##### enableElevatedUpdateTask `boolean` Create an elevated update task within Windows Task Scheduler. ##### featureGroupRefs `string`\[] The FeatureGroup element ids you want to reference from the fragments. **Default**: `[]` ##### featureRefs `string`\[] The Feature element ids you want to reference from the fragments. **Default**: `[]` ##### fipsCompliant `boolean` Enables FIPS compliant algorithms. Can also be enabled via the `TAURI_BUNDLER_WIX_FIPS_COMPLIANT` env var. ##### fragmentPaths `string`\[] A list of paths to .wxs files with WiX fragments to use. **Default**: `[]` ##### language [`WixLanguage`](#wixlanguage) The installer languages to build. See <>. **Default**: `"en-US"` ##### mergeRefs `string`\[] The Merge element ids you want to reference from the fragments. **Default**: `[]` ##### template `string` | `null` A custom .wxs template to use. ##### upgradeCode `string` | `null` formatted as `uuid` A GUID upgrade code for MSI installer. This code ***must stay the same across all of your updates***, otherwise, Windows will treat your update as a different app and your users will have duplicate versions of your app. By default, tauri generates this code by generating a Uuid v5 using the string `<productName>.exe.app.x64` in the DNS namespace. You can use Tauri’s CLI to generate and print this code for you, run `tauri inspect wix-upgrade-code`. It is recommended that you set this value in your tauri config file to avoid accidental changes in your upgrade code whenever you want to change your product name. ##### version `string` | `null` MSI installer version in the format `major.minor.patch.build` (build is optional). Because a valid version is required for MSI installer, it will be derived from \[`Config::version`] if this field is not set. The first field is the major version and has a maximum value of 255. The second field is the minor version and has a maximum value of 255. The third and fourth fields have a maximum value of 65,535. See <> for more info. ### WixLanguage **Any of the following**: * `string` A single language to build, without configuration. * `string`\[] A list of languages to build, without configuration. * A map of languages and its configuration. **Allows additional properties**: [`WixLanguageConfig`](#wixlanguageconfig) The languages to build using WiX. ### WixLanguageConfig Configuration for a target language for the WiX build. See more: <> **Object Properties**: * localePath ##### localePath `string` | `null` The path to a locale (`.wxl`) file. See <>. # Environment Variables This is a documentation of all environment variables used by tauri core crates and tauri CLI. ## Tauri CLI These environment variables are inputs to the CLI which may have an equivalent CLI flag. * `CI` — If set, the CLI will run in CI mode and won’t require any user interaction. * `TAURI_CLI_CONFIG_DEPTH` — Number of levels to traverse and find tauri configuration file. * `TAURI_CLI_PORT` — Port to use for the CLI built-in dev server. * `TAURI_CLI_WATCHER_IGNORE_FILENAME` — Name of a `.gitignore`-style file to control which files should be watched by the CLI in `dev` command. The CLI will look for this file name in each directory. * `TAURI_CLI_NO_DEV_SERVER_WAIT` — Skip waiting for the frontend dev server to start before building the tauri application. * `TAURI_LINUX_AYATANA_APPINDICATOR` — Set this var to `true` or `1` to force usage of `libayatana-appindicator` for system tray on Linux. * `TAURI_BUNDLER_WIX_FIPS_COMPLIANT` — Specify the bundler’s WiX `FipsCompliant` option. * `TAURI_BUNDLER_TOOLS_GITHUB_MIRROR` - Specify a GitHub mirror to download files and tools used by tauri bundler. * `TAURI_BUNDLER_TOOLS_GITHUB_MIRROR_TEMPLATE` - Specify a GitHub mirror template to download files and tools used by tauri bundler, for example: `https://mirror.example.com///releases/download//`. * `TAURI_SKIP_SIDECAR_SIGNATURE_CHECK` - Skip signing sidecars. * `TAURI_SIGNING_PRIVATE_KEY` — Private key used to sign your app bundles, can be either a string or a path to the file. * `TAURI_SIGNING_PRIVATE_KEY_PASSWORD` — The signing private key password, see `TAURI_SIGNING_PRIVATE_KEY`. * `TAURI_SIGNING_RPM_KEY` — The private GPG key used to sign the RPM bundle, exported to its ASCII-armored format. * `TAURI_SIGNING_RPM_KEY_PASSPHRASE` — The GPG key passphrase for `TAURI_SIGNING_RPM_KEY`, if needed. * `TAURI_WINDOWS_SIGNTOOL_PATH` — Specify a path to `signtool.exe` used for code signing the application on Windows. * `APPLE_CERTIFICATE` — Base64 encoded of the `.p12` certificate for code signing. To get this value, run `openssl base64 -A -in MyCertificate.p12 -out MyCertificate-base64.txt`. * `APPLE_CERTIFICATE_PASSWORD` — The password you used to export the certificate. * `APPLE_ID` — The Apple ID used to notarize the application. If this environment variable is provided, `APPLE_PASSWORD` and `APPLE_TEAM_ID` must also be set. Alternatively, `APPLE_API_KEY` and `APPLE_API_ISSUER` can be used to authenticate. * `APPLE_PASSWORD` — The Apple password used to authenticate for application notarization. Required if `APPLE_ID` is specified. An [app-specific password](https://support.apple.com/en-ca/HT204397) can be used. Alternatively to entering the password in plaintext, it may also be specified using a ‘@keychain:’ or ‘@env:’ prefix followed by a keychain password item name or environment variable name. * `APPLE_TEAM_ID`: Developer team ID. To find your Team ID, go to the [Account](https://developer.apple.com/account) page on the Apple Developer website, and check your membership details. * `APPLE_API_KEY` — Alternative to `APPLE_ID` and `APPLE_PASSWORD` for notarization authentication using JWT. Also an option to allow automated iOS certificate and provisioning profile management. * See [creating API keys](https://developer.apple.com/documentation/appstoreconnectapi/creating_api_keys_for_app_store_connect_api) for more information. * `API_PRIVATE_KEYS_DIR` — Specify the directory where your AuthKey file is located. See `APPLE_API_KEY`. * `APPLE_API_ISSUER` — Issuer ID. Required if `APPLE_API_KEY` is specified. * `APPLE_API_KEY_PATH` - path to the API key `.p8` file. If not specified, for macOS apps the bundler searches the following directories in sequence for a private key file with the name of ‘AuthKey\_\.p8’: ‘./private\_keys’, ‘~~/private\_keys’, ‘~~/.private\_keys’, and ‘\~/.appstoreconnect/private\_keys’. **For iOS this variable is required**. * `APPLE_SIGNING_IDENTITY` — The identity used to code sign. Overwrites `tauri.conf.json > bundle > macOS > signingIdentity`. If neither are set, it is inferred from `APPLE_CERTIFICATE` when provided. * `APPLE_PROVIDER_SHORT_NAME` — If your Apple ID is connected to multiple teams, you have to specify the provider short name of the team you want to use to notarize your app. Overwrites `tauri.conf.json > bundle > macOS > providerShortName`. * `APPLE_DEVELOPMENT_TEAM` — The team ID used to code sign on iOS. Overwrites `tauri.conf.json > bundle > iOS > developmentTeam`. Can be found in . * `TAURI_WEBVIEW_AUTOMATION` — Enables webview automation (Linux Only). * `TAURI_ANDROID_PROJECT_PATH` — Path of the tauri android project, usually will be `/src-tauri/gen/android`. * `TAURI_IOS_PROJECT_PATH` — Path of the tauri iOS project, usually will be `/src-tauri/gen/ios`. ## Tauri CLI Hook Commands These environment variables are set for each hook command (`beforeDevCommand`, `beforeBuildCommand`, …etc) which could be useful to conditionally build your frontend or execute a specific action. * `TAURI_ENV_DEBUG` — `true` for `dev` command or `build --debug`, `false` otherwise. * `TAURI_ENV_TARGET_TRIPLE` — Target triple the CLI is building. * `TAURI_ENV_ARCH` — Target arch, `x86_64`, `aarch64`…etc. * `TAURI_ENV_PLATFORM` — Target platform, `windows`, `darwin`, `linux`…etc. * `TAURI_ENV_PLATFORM_VERSION` — Build platform version * `TAURI_ENV_FAMILY` — Target platform family `unix` or `windows`. # @tauri-apps/api The Tauri API allows you to interface with the backend layer. This module exposes all other modules as an object where the key is the module name, and the value is the module exports. ## Examples ```typescript import { event, window, path } from '@tauri-apps/api' ``` ### Vanilla JS API The above import syntax is for JavaScript/TypeScript with a bundler. If you’re using vanilla JavaScript, you can use the global `window.__TAURI__` object instead. It requires `app.withGlobalTauri` configuration option enabled. ```js const { event, window: tauriWindow, path } = window.__TAURI__; ``` ## Namespaces * [app](/reference/javascript/api/namespaceapp/) * [core](/reference/javascript/api/namespacecore/) * [dpi](/reference/javascript/api/namespacedpi/) * [event](/reference/javascript/api/namespaceevent/) * [image](/reference/javascript/api/namespaceimage/) * [menu](/reference/javascript/api/namespacemenu/) * [mocks](/reference/javascript/api/namespacemocks/) * [path](/reference/javascript/api/namespacepath/) * [tray](/reference/javascript/api/namespacetray/) * [webview](/reference/javascript/api/namespacewebview/) * [webviewWindow](/reference/javascript/api/namespacewebviewwindow/) * [window](/reference/javascript/api/namespacewindow/) # app ## Enumerations []() ### BundleType Bundle type of the current application. #### Enumeration Members []() ##### App ```ts App: "app"; ``` macOS app bundle **Source**: []() ##### AppImage ```ts AppImage: "appimage"; ``` Linux AppImage **Source**: []() ##### Deb ```ts Deb: "deb"; ``` Linux Debian package **Source**: []() ##### Msi ```ts Msi: "msi"; ``` Windows MSI **Source**: []() ##### Nsis ```ts Nsis: "nsis"; ``` Windows NSIS **Source**: []() ##### Rpm ```ts Rpm: "rpm"; ``` Linux RPM **Source**: ## Type Aliases []() ### DataStoreIdentifier ```ts type DataStoreIdentifier: [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number]; ``` Identifier type used for data stores on macOS and iOS. Represents a 128-bit identifier, commonly expressed as a 16-byte UUID. **Source**: *** []() ### OnBackButtonPressPayload ```ts type OnBackButtonPressPayload: object; ``` Payload for the onBackButtonPress event. #### Type declaration | Name | Type | Description | Defined in | | ----------- | --------- | ----------------------------------------------- | --------------------------------------------------------------------------------------- | | `canGoBack` | `boolean` | Whether the webview canGoBack property is true. | **Source**: | **Source**: ## Functions []() ### defaultWindowIcon() ```ts function defaultWindowIcon(): Promise ``` Gets the default window icon. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Image`](/reference/javascript/api/namespaceimage/#image) | `null`> #### Example ```typescript import { defaultWindowIcon } from '@tauri-apps/api/app'; const icon = await defaultWindowIcon(); ``` #### Since 2.0.0 **Source**: *** []() ### fetchDataStoreIdentifiers() ```ts function fetchDataStoreIdentifiers(): Promise ``` Fetches the data store identifiers on macOS and iOS. See for more information. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`DataStoreIdentifier`](/reference/javascript/api/namespaceapp/#datastoreidentifier)\[]> #### Example ```typescript import { fetchDataStoreIdentifiers } from '@tauri-apps/api/app'; const ids = await fetchDataStoreIdentifiers(); ``` #### Since 2.4.0 **Source**: *** []() ### getBundleType() ```ts function getBundleType(): Promise ``` Gets the application bundle type. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`BundleType`](/reference/javascript/api/namespaceapp/#bundletype)> #### Example ```typescript import { getBundleType } from '@tauri-apps/api/app'; const type = await getBundleType(); ``` #### Since 2.5.0 **Source**: *** []() ### getIdentifier() ```ts function getIdentifier(): Promise ``` Gets the application identifier. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> The application identifier as configured in `tauri.conf.json`. #### Example ```typescript import { getIdentifier } from '@tauri-apps/api/app'; const identifier = await getIdentifier(); ``` #### Since 2.4.0 **Source**: *** []() ### getName() ```ts function getName(): Promise ``` Gets the application name. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> #### Example ```typescript import { getName } from '@tauri-apps/api/app'; const appName = await getName(); ``` #### Since 1.0.0 **Source**: *** []() ### getTauriVersion() ```ts function getTauriVersion(): Promise ``` Gets the Tauri framework version used by this application. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> #### Example ```typescript import { getTauriVersion } from '@tauri-apps/api/app'; const tauriVersion = await getTauriVersion(); ``` #### Since 1.0.0 **Source**: *** []() ### getVersion() ```ts function getVersion(): Promise ``` Gets the application version. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> #### Example ```typescript import { getVersion } from '@tauri-apps/api/app'; const appVersion = await getVersion(); ``` #### Since 1.0.0 **Source**: *** []() ### hide() ```ts function hide(): Promise ``` Hides the application on macOS. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> #### Example ```typescript import { hide } from '@tauri-apps/api/app'; await hide(); ``` #### Since 1.2.0 **Source**: *** []() ### onBackButtonPress() ```ts function onBackButtonPress(handler): Promise ``` Listens to the backButton event on Android. #### Parameters | Parameter | Type | Description | | --------- | --------------------- | ----------- | | `handler` | (`payload`) => `void` | | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`PluginListener`](/reference/javascript/api/namespacecore/#pluginlistener)> **Source**: *** []() ### removeDataStore() ```ts function removeDataStore(uuid): Promise ``` Removes the data store with the given identifier. Note that any webview using this data store should be closed before running this API. See for more information. #### Parameters | Parameter | Type | | --------- | ------------------------------------------------------------------------------------ | | `uuid` | [`DataStoreIdentifier`](/reference/javascript/api/namespaceapp/#datastoreidentifier) | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> #### Example ```typescript import { fetchDataStoreIdentifiers, removeDataStore } from '@tauri-apps/api/app'; for (const id of (await fetchDataStoreIdentifiers())) { await removeDataStore(id); } ``` #### Since 2.4.0 **Source**: *** []() ### setDockVisibility() ```ts function setDockVisibility(visible): Promise ``` Sets the dock visibility for the application on macOS. #### Parameters | Parameter | Type | Description | | --------- | --------- | ------------------------------------------ | | `visible` | `boolean` | Whether the dock should be visible or not. | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> #### Example ```typescript import { setDockVisibility } from '@tauri-apps/api/app'; await setDockVisibility(false); ``` #### Since 2.5.0 **Source**: *** []() ### setTheme() ```ts function setTheme(theme?): Promise ``` Sets the application’s theme. Pass in `null` or `undefined` to follow the system theme. #### Parameters | Parameter | Type | | --------- | ----------------------------------------------------------------------- | | `theme`? | `null` \| [`Theme`](/reference/javascript/api/namespacewindow/#theme-2) | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> #### Example ```typescript import { setTheme } from '@tauri-apps/api/app'; await setTheme('dark'); ``` Platform-specific * **iOS / Android:** Unsupported. #### Since 2.0.0 **Source**: *** []() ### show() ```ts function show(): Promise ``` Shows the application on macOS. This function does not automatically focus any specific app window. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> #### Example ```typescript import { show } from '@tauri-apps/api/app'; await show(); ``` #### Since 1.2.0 **Source**: *** []() ### supportsMultipleWindows() ```ts function supportsMultipleWindows(): Promise ``` #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> **Source**: # core Invoke your custom commands. This package is also accessible with `window.__TAURI__.core` when [`app.withGlobalTauri`](https://v2.tauri.app/reference/config/#withglobaltauri) in `tauri.conf.json` is set to `true`. ## Classes []() ### Channel\ #### Type Parameters | Type Parameter | Default type | | -------------- | ------------ | | `T` | `unknown` | #### Constructors []() ##### new Channel() ```ts new Channel(onmessage?): Channel ``` ###### Parameters | Parameter | Type | | ------------ | ---------------------- | | `onmessage`? | (`response`) => `void` | ###### Returns [`Channel`](/reference/javascript/api/namespacecore/#channelt)<`T`> **Source**: #### Properties | Property | Type | Description | Defined in | | -------- | -------- | --------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | | []()`id` | `number` | The callback id returned from [`transformCallback`](/reference/javascript/api/namespacecore/#transformcallback) | **Source**: | #### Accessors []() ##### onmessage ```ts get onmessage(): (response) => void ``` ```ts set onmessage(handler): void ``` ###### Parameters | Parameter | Type | | --------- | ---------------------- | | `handler` | (`response`) => `void` | ###### Returns `Function` ###### Parameters | Parameter | Type | | ---------- | ---- | | `response` | `T` | ###### Returns `void` **Source**: #### Methods []() ##### \_\_TAURI\_TO\_IPC\_KEY\_\_() ```ts __TAURI_TO_IPC_KEY__(): string ``` ###### Returns `string` **Source**: []() ##### toJSON() ```ts toJSON(): string ``` ###### Returns `string` **Source**: *** []() ### PluginListener #### Constructors []() ##### new PluginListener() ```ts new PluginListener( plugin, event, channelId): PluginListener ``` ###### Parameters | Parameter | Type | | ----------- | -------- | | `plugin` | `string` | | `event` | `string` | | `channelId` | `number` | ###### Returns [`PluginListener`](/reference/javascript/api/namespacecore/#pluginlistener) **Source**: #### Properties | Property | Type | Defined in | | --------------- | -------- | ---------------------------------------------------------------------------------------- | | []()`channelId` | `number` | **Source**: | | []()`event` | `string` | **Source**: | | []()`plugin` | `string` | **Source**: | #### Methods []() ##### unregister() ```ts unregister(): Promise ``` ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: *** []() ### Resource A rust-backed resource stored through `tauri::Manager::resources_table` API. The resource lives in the main process and does not exist in the Javascript world, and thus will not be cleaned up automatically except on application exit. If you want to clean it up early, call [`Resource.close`](/reference/javascript/api/namespacecore/#close) #### Example ```typescript import { Resource, invoke } from '@tauri-apps/api/core'; export class DatabaseHandle extends Resource { static async open(path: string): Promise { const rid: number = await invoke('open_db', { path }); return new DatabaseHandle(rid); } async execute(sql: string): Promise { await invoke('execute_sql', { rid: this.rid, sql }); } } ``` #### Extended by * [`Image`](/reference/javascript/api/namespaceimage/#image) * [`TrayIcon`](/reference/javascript/api/namespacetray/#trayicon) #### Constructors []() ##### new Resource() ```ts new Resource(rid): Resource ``` ###### Parameters | Parameter | Type | | --------- | -------- | | `rid` | `number` | ###### Returns [`Resource`](/reference/javascript/api/namespacecore/#resource) **Source**: #### Accessors []() ##### rid ```ts get rid(): number ``` ###### Returns `number` **Source**: #### Methods []() ##### close() ```ts close(): Promise ``` Destroys and cleans up this resource from memory. **You should not call any method on this object anymore and should drop any reference to it.** ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: ## Interfaces []() ### InvokeOptions #### Since 2.0.0 #### Properties | Property | Type | Defined in | | ------------- | ------------- | ---------------------------------------------------------------------------------------- | | []()`headers` | `HeadersInit` | **Source**: | ## Type Aliases []() ### InvokeArgs ```ts type InvokeArgs: Record | number[] | ArrayBuffer | Uint8Array; ``` Command arguments. #### Since 1.0.0 **Source**: *** []() ### PermissionState ```ts type PermissionState: "granted" | "denied" | "prompt" | "prompt-with-rationale"; ``` **Source**: ## Variables []() ### SERIALIZE\_TO\_IPC\_FN ```ts const SERIALIZE_TO_IPC_FN: "__TAURI_TO_IPC_KEY__" = '__TAURI_TO_IPC_KEY__'; ``` A key to be used to implement a special function on your types that define how your type should be serialized when passing across the IPC. #### Example Given a type in Rust that looks like this ```rs #[derive(serde::Serialize, serde::Deserialize) enum UserId { String(String), Number(u32), } ``` `UserId::String("id")` would be serialized into `{ String: "id" }` and so we need to pass the same structure back to Rust ```ts import { SERIALIZE_TO_IPC_FN } from "@tauri-apps/api/core" class UserIdString { id constructor(id) { this.id = id } [SERIALIZE_TO_IPC_FN]() { return { String: this.id } } } class UserIdNumber { id constructor(id) { this.id = id } [SERIALIZE_TO_IPC_FN]() { return { Number: this.id } } } type UserId = UserIdString | UserIdNumber ``` **Source**: ## Functions []() ### addPluginListener() ```ts function addPluginListener( plugin, event, cb): Promise ``` Adds a listener to a plugin event. #### Type Parameters | Type Parameter | | -------------- | | `T` | #### Parameters | Parameter | Type | | --------- | --------------------- | | `plugin` | `string` | | `event` | `string` | | `cb` | (`payload`) => `void` | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`PluginListener`](/reference/javascript/api/namespacecore/#pluginlistener)> The listener object to stop listening to the events. #### Since 2.0.0 **Source**: *** []() ### checkPermissions() ```ts function checkPermissions(plugin): Promise ``` Get permission state for a plugin. This should be used by plugin authors to wrap their actual implementation. #### Type Parameters | Type Parameter | | -------------- | | `T` | #### Parameters | Parameter | Type | | --------- | -------- | | `plugin` | `string` | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`T`> **Source**: *** []() ### convertFileSrc() ```ts function convertFileSrc(filePath, protocol): string ``` Convert a device file path to an URL that can be loaded by the webview. Note that `asset:` and `http://asset.localhost` must be added to [`app.security.csp`](https://v2.tauri.app/reference/config/#csp-1) in `tauri.conf.json`. Example CSP value: `"csp": "default-src 'self' ipc: http://ipc.localhost; img-src 'self' asset: http://asset.localhost"` to use the asset protocol on image sources. Additionally, `"enable" : "true"` must be added to [`app.security.assetProtocol`](https://v2.tauri.app/reference/config/#assetprotocolconfig) in `tauri.conf.json` and its access scope must be defined on the `scope` array on the same `assetProtocol` object. #### Parameters | Parameter | Type | Default value | Description | | ---------- | -------- | ------------- | ------------------------------------------------------------------------------------------------- | | `filePath` | `string` | `undefined` | The file path. | | `protocol` | `string` | `'asset'` | The protocol to use. Defaults to `asset`. You only need to set this when using a custom protocol. | #### Returns `string` the URL that can be used as source on the webview. #### Example ```typescript import { appDataDir, join } from '@tauri-apps/api/path'; import { convertFileSrc } from '@tauri-apps/api/core'; const appDataDirPath = await appDataDir(); const filePath = await join(appDataDirPath, 'assets/video.mp4'); const assetUrl = convertFileSrc(filePath); const video = document.getElementById('my-video'); const source = document.createElement('source'); source.type = 'video/mp4'; source.src = assetUrl; video.appendChild(source); video.load(); ``` #### Since 1.0.0 **Source**: *** []() ### invoke() ```ts function invoke( cmd, args, options?): Promise ``` Sends a message to the backend. #### Type Parameters | Type Parameter | | -------------- | | `T` | #### Parameters | Parameter | Type | Description | | ---------- | ------------------------------------------------------------------------- | ---------------------------------------------- | | `cmd` | `string` | The command name. | | `args` | [`InvokeArgs`](/reference/javascript/api/namespacecore/#invokeargs) | The optional arguments to pass to the command. | | `options`? | [`InvokeOptions`](/reference/javascript/api/namespacecore/#invokeoptions) | The request options. | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`T`> A promise resolving or rejecting to the backend response. #### Example ```typescript import { invoke } from '@tauri-apps/api/core'; await invoke('login', { user: 'tauri', password: 'poiwe3h4r5ip3yrhtew9ty' }); ``` #### Since 1.0.0 **Source**: *** []() ### isTauri() ```ts function isTauri(): boolean ``` #### Returns `boolean` **Source**: *** []() ### requestPermissions() ```ts function requestPermissions(plugin): Promise ``` Request permissions. This should be used by plugin authors to wrap their actual implementation. #### Type Parameters | Type Parameter | | -------------- | | `T` | #### Parameters | Parameter | Type | | --------- | -------- | | `plugin` | `string` | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`T`> **Source**: *** []() ### transformCallback() ```ts function transformCallback(callback?, once?): number ``` Stores the callback in a known location, and returns an identifier that can be passed to the backend. The backend uses the identifier to `eval()` the callback. #### Type Parameters | Type Parameter | Default type | | -------------- | ------------ | | `T` | `unknown` | #### Parameters | Parameter | Type | Default value | | ----------- | ---------------------- | ------------- | | `callback`? | (`response`) => `void` | `undefined` | | `once`? | `boolean` | `false` | #### Returns `number` An unique identifier associated with the callback function. #### Since 1.0.0 **Source**: # dpi ## Classes []() ### LogicalPosition A position represented in logical pixels. For an explanation of what logical pixels are, see description of [`LogicalSize`](/reference/javascript/api/namespacedpi/#logicalsize). #### Since 2.0.0 #### Constructors []() ##### new LogicalPosition() ```ts new LogicalPosition(x, y): LogicalPosition ``` ###### Parameters | Parameter | Type | | --------- | -------- | | `x` | `number` | | `y` | `number` | ###### Returns [`LogicalPosition`](/reference/javascript/api/namespacedpi/#logicalposition) **Source**: ##### new LogicalPosition() ```ts new LogicalPosition(object): LogicalPosition ``` ###### Parameters | Parameter | Type | | ------------------ | -------- | | `object` | `object` | | `object.Logical` | `object` | | `object.Logical.x` | `number` | | `object.Logical.y` | `number` | ###### Returns [`LogicalPosition`](/reference/javascript/api/namespacedpi/#logicalposition) **Source**: ##### new LogicalPosition() ```ts new LogicalPosition(object): LogicalPosition ``` ###### Parameters | Parameter | Type | | ---------- | -------- | | `object` | `object` | | `object.x` | `number` | | `object.y` | `number` | ###### Returns [`LogicalPosition`](/reference/javascript/api/namespacedpi/#logicalposition) **Source**: #### Properties | Property | Modifier | Type | Default value | Defined in | | ---------- | ---------- | ----------- | ------------- | --------------------------------------------------------------------------------------- | | []()`type` | `readonly` | `"Logical"` | `'Logical'` | **Source**: | | []()`x` | `public` | `number` | `undefined` | **Source**: | | []()`y` | `public` | `number` | `undefined` | **Source**: | #### Methods []() ##### \_\_TAURI\_TO\_IPC\_KEY\_\_() ```ts __TAURI_TO_IPC_KEY__(): object ``` ###### Returns `object` | Name | Type | Defined in | | ---- | -------- | --------------------------------------------------------------------------------------- | | `x` | `number` | **Source**: | | `y` | `number` | **Source**: | **Source**: []() ##### toJSON() ```ts toJSON(): object ``` ###### Returns `object` | Name | Type | Defined in | | ---- | -------- | --------------------------------------------------------------------------------------- | | `x` | `number` | **Source**: | | `y` | `number` | **Source**: | **Source**: []() ##### toPhysical() ```ts toPhysical(scaleFactor): PhysicalPosition ``` Converts the logical position to a physical one. ###### Parameters | Parameter | Type | | ------------- | -------- | | `scaleFactor` | `number` | ###### Returns [`PhysicalPosition`](/reference/javascript/api/namespacedpi/#physicalposition) ###### Example ```typescript import { LogicalPosition } from '@tauri-apps/api/dpi'; import { getCurrentWindow } from '@tauri-apps/api/window'; const appWindow = getCurrentWindow(); const factor = await appWindow.scaleFactor(); const position = new LogicalPosition(400, 500); const physical = position.toPhysical(factor); ``` ###### Since 2.0.0 **Source**: *** []() ### LogicalSize A size represented in logical pixels. Logical pixels are scaled according to the window’s DPI scale. Most browser APIs (i.e. `MouseEvent`’s `clientX`) will return logical pixels. For logical-pixel-based position, see [`LogicalPosition`](/reference/javascript/api/namespacedpi/#logicalposition). #### Since 2.0.0 #### Constructors []() ##### new LogicalSize() ```ts new LogicalSize(width, height): LogicalSize ``` ###### Parameters | Parameter | Type | | --------- | -------- | | `width` | `number` | | `height` | `number` | ###### Returns [`LogicalSize`](/reference/javascript/api/namespacedpi/#logicalsize) **Source**: ##### new LogicalSize() ```ts new LogicalSize(object): LogicalSize ``` ###### Parameters | Parameter | Type | | ----------------------- | -------- | | `object` | `object` | | `object.Logical` | `object` | | `object.Logical.height` | `number` | | `object.Logical.width` | `number` | ###### Returns [`LogicalSize`](/reference/javascript/api/namespacedpi/#logicalsize) **Source**: ##### new LogicalSize() ```ts new LogicalSize(object): LogicalSize ``` ###### Parameters | Parameter | Type | | --------------- | -------- | | `object` | `object` | | `object.height` | `number` | | `object.width` | `number` | ###### Returns [`LogicalSize`](/reference/javascript/api/namespacedpi/#logicalsize) **Source**: #### Properties | Property | Modifier | Type | Default value | Defined in | | ------------ | ---------- | ----------- | ------------- | -------------------------------------------------------------------------------------- | | []()`height` | `public` | `number` | `undefined` | **Source**: | | []()`type` | `readonly` | `"Logical"` | `'Logical'` | **Source**: | | []()`width` | `public` | `number` | `undefined` | **Source**: | #### Methods []() ##### \_\_TAURI\_TO\_IPC\_KEY\_\_() ```ts __TAURI_TO_IPC_KEY__(): object ``` ###### Returns `object` | Name | Type | Defined in | | -------- | -------- | -------------------------------------------------------------------------------------- | | `height` | `number` | **Source**: | | `width` | `number` | **Source**: | **Source**: []() ##### toJSON() ```ts toJSON(): object ``` ###### Returns `object` | Name | Type | Defined in | | -------- | -------- | -------------------------------------------------------------------------------------- | | `height` | `number` | **Source**: | | `width` | `number` | **Source**: | **Source**: []() ##### toPhysical() ```ts toPhysical(scaleFactor): PhysicalSize ``` Converts the logical size to a physical one. ###### Parameters | Parameter | Type | | ------------- | -------- | | `scaleFactor` | `number` | ###### Returns [`PhysicalSize`](/reference/javascript/api/namespacedpi/#physicalsize) ###### Example ```typescript import { LogicalSize } from '@tauri-apps/api/dpi'; import { getCurrentWindow } from '@tauri-apps/api/window'; const appWindow = getCurrentWindow(); const factor = await appWindow.scaleFactor(); const size = new LogicalSize(400, 500); const physical = size.toPhysical(factor); ``` ###### Since 2.0.0 **Source**: *** []() ### PhysicalPosition A position represented in physical pixels. For an explanation of what physical pixels are, see description of [`PhysicalSize`](/reference/javascript/api/namespacedpi/#physicalsize). #### Since 2.0.0 #### Constructors []() ##### new PhysicalPosition() ```ts new PhysicalPosition(x, y): PhysicalPosition ``` ###### Parameters | Parameter | Type | | --------- | -------- | | `x` | `number` | | `y` | `number` | ###### Returns [`PhysicalPosition`](/reference/javascript/api/namespacedpi/#physicalposition) **Source**: ##### new PhysicalPosition() ```ts new PhysicalPosition(object): PhysicalPosition ``` ###### Parameters | Parameter | Type | | ------------------- | -------- | | `object` | `object` | | `object.Physical` | `object` | | `object.Physical.x` | `number` | | `object.Physical.y` | `number` | ###### Returns [`PhysicalPosition`](/reference/javascript/api/namespacedpi/#physicalposition) **Source**: ##### new PhysicalPosition() ```ts new PhysicalPosition(object): PhysicalPosition ``` ###### Parameters | Parameter | Type | | ---------- | -------- | | `object` | `object` | | `object.x` | `number` | | `object.y` | `number` | ###### Returns [`PhysicalPosition`](/reference/javascript/api/namespacedpi/#physicalposition) **Source**: #### Properties | Property | Modifier | Type | Default value | Defined in | | ---------- | ---------- | ------------ | ------------- | --------------------------------------------------------------------------------------- | | []()`type` | `readonly` | `"Physical"` | `'Physical'` | **Source**: | | []()`x` | `public` | `number` | `undefined` | **Source**: | | []()`y` | `public` | `number` | `undefined` | **Source**: | #### Methods []() ##### \_\_TAURI\_TO\_IPC\_KEY\_\_() ```ts __TAURI_TO_IPC_KEY__(): object ``` ###### Returns `object` | Name | Type | Defined in | | ---- | -------- | --------------------------------------------------------------------------------------- | | `x` | `number` | **Source**: | | `y` | `number` | **Source**: | **Source**: []() ##### toJSON() ```ts toJSON(): object ``` ###### Returns `object` | Name | Type | Defined in | | ---- | -------- | --------------------------------------------------------------------------------------- | | `x` | `number` | **Source**: | | `y` | `number` | **Source**: | **Source**: []() ##### toLogical() ```ts toLogical(scaleFactor): LogicalPosition ``` Converts the physical position to a logical one. ###### Parameters | Parameter | Type | | ------------- | -------- | | `scaleFactor` | `number` | ###### Returns [`LogicalPosition`](/reference/javascript/api/namespacedpi/#logicalposition) ###### Example ```typescript import { PhysicalPosition } from '@tauri-apps/api/dpi'; import { getCurrentWindow } from '@tauri-apps/api/window'; const appWindow = getCurrentWindow(); const factor = await appWindow.scaleFactor(); const position = new PhysicalPosition(400, 500); const physical = position.toLogical(factor); ``` ###### Since 2.0.0 **Source**: *** []() ### PhysicalSize A size represented in physical pixels. Physical pixels represent actual screen pixels, and are DPI-independent. For high-DPI windows, this means that any point in the window on the screen will have a different position in logical pixels [`LogicalSize`](/reference/javascript/api/namespacedpi/#logicalsize). For physical-pixel-based position, see [`PhysicalPosition`](/reference/javascript/api/namespacedpi/#physicalposition). #### Since 2.0.0 #### Constructors []() ##### new PhysicalSize() ```ts new PhysicalSize(width, height): PhysicalSize ``` ###### Parameters | Parameter | Type | | --------- | -------- | | `width` | `number` | | `height` | `number` | ###### Returns [`PhysicalSize`](/reference/javascript/api/namespacedpi/#physicalsize) **Source**: ##### new PhysicalSize() ```ts new PhysicalSize(object): PhysicalSize ``` ###### Parameters | Parameter | Type | | ------------------------ | -------- | | `object` | `object` | | `object.Physical` | `object` | | `object.Physical.height` | `number` | | `object.Physical.width` | `number` | ###### Returns [`PhysicalSize`](/reference/javascript/api/namespacedpi/#physicalsize) **Source**: ##### new PhysicalSize() ```ts new PhysicalSize(object): PhysicalSize ``` ###### Parameters | Parameter | Type | | --------------- | -------- | | `object` | `object` | | `object.height` | `number` | | `object.width` | `number` | ###### Returns [`PhysicalSize`](/reference/javascript/api/namespacedpi/#physicalsize) **Source**: #### Properties | Property | Modifier | Type | Default value | Defined in | | ------------ | ---------- | ------------ | ------------- | -------------------------------------------------------------------------------------- | | []()`height` | `public` | `number` | `undefined` | **Source**: | | []()`type` | `readonly` | `"Physical"` | `'Physical'` | **Source**: | | []()`width` | `public` | `number` | `undefined` | **Source**: | #### Methods []() ##### \_\_TAURI\_TO\_IPC\_KEY\_\_() ```ts __TAURI_TO_IPC_KEY__(): object ``` ###### Returns `object` | Name | Type | Defined in | | -------- | -------- | --------------------------------------------------------------------------------------- | | `height` | `number` | **Source**: | | `width` | `number` | **Source**: | **Source**: []() ##### toJSON() ```ts toJSON(): object ``` ###### Returns `object` | Name | Type | Defined in | | -------- | -------- | --------------------------------------------------------------------------------------- | | `height` | `number` | **Source**: | | `width` | `number` | **Source**: | **Source**: []() ##### toLogical() ```ts toLogical(scaleFactor): LogicalSize ``` Converts the physical size to a logical one. ###### Parameters | Parameter | Type | | ------------- | -------- | | `scaleFactor` | `number` | ###### Returns [`LogicalSize`](/reference/javascript/api/namespacedpi/#logicalsize) ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const appWindow = getCurrentWindow(); const factor = await appWindow.scaleFactor(); const size = await appWindow.innerSize(); // PhysicalSize const logical = size.toLogical(factor); ``` **Source**: *** []() ### Position A position represented either in physical or in logical pixels. This type is basically a union type of [`LogicalSize`](/reference/javascript/api/namespacedpi/#logicalsize) and [`PhysicalSize`](/reference/javascript/api/namespacedpi/#physicalsize) but comes in handy when using `tauri::Position` in Rust as an argument to a command, as this class automatically serializes into a valid format so it can be deserialized correctly into `tauri::Position` So instead of ```typescript import { invoke } from '@tauri-apps/api/core'; import { LogicalPosition, PhysicalPosition } from '@tauri-apps/api/dpi'; const position: LogicalPosition | PhysicalPosition = someFunction(); // where someFunction returns either LogicalPosition or PhysicalPosition const validPosition = position instanceof LogicalPosition ? { Logical: { x: position.x, y: position.y } } : { Physical: { x: position.x, y: position.y } } await invoke("do_something_with_position", { position: validPosition }); ``` You can just use [`Position`](/reference/javascript/api/namespacedpi/#position) ```typescript import { invoke } from '@tauri-apps/api/core'; import { LogicalPosition, PhysicalPosition, Position } from '@tauri-apps/api/dpi'; const position: LogicalPosition | PhysicalPosition = someFunction(); // where someFunction returns either LogicalPosition or PhysicalPosition const validPosition = new Position(position); await invoke("do_something_with_position", { position: validPosition }); ``` #### Since 2.1.0 #### Constructors []() ##### new Position() ```ts new Position(position): Position ``` ###### Parameters | Parameter | Type | | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `position` | [`LogicalPosition`](/reference/javascript/api/namespacedpi/#logicalposition) \| [`PhysicalPosition`](/reference/javascript/api/namespacedpi/#physicalposition) | ###### Returns [`Position`](/reference/javascript/api/namespacedpi/#position) **Source**: #### Properties | Property | Type | Defined in | | -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | | []()`position` | [`LogicalPosition`](/reference/javascript/api/namespacedpi/#logicalposition) \| [`PhysicalPosition`](/reference/javascript/api/namespacedpi/#physicalposition) | **Source**: | #### Methods []() ##### \_\_TAURI\_TO\_IPC\_KEY\_\_() ```ts __TAURI_TO_IPC_KEY__(): object ``` ###### Returns `object` **Source**: []() ##### toJSON() ```ts toJSON(): object ``` ###### Returns `object` **Source**: []() ##### toLogical() ```ts toLogical(scaleFactor): LogicalPosition ``` ###### Parameters | Parameter | Type | | ------------- | -------- | | `scaleFactor` | `number` | ###### Returns [`LogicalPosition`](/reference/javascript/api/namespacedpi/#logicalposition) **Source**: []() ##### toPhysical() ```ts toPhysical(scaleFactor): PhysicalPosition ``` ###### Parameters | Parameter | Type | | ------------- | -------- | | `scaleFactor` | `number` | ###### Returns [`PhysicalPosition`](/reference/javascript/api/namespacedpi/#physicalposition) **Source**: *** []() ### Size A size represented either in physical or in logical pixels. This type is basically a union type of [`LogicalSize`](/reference/javascript/api/namespacedpi/#logicalsize) and [`PhysicalSize`](/reference/javascript/api/namespacedpi/#physicalsize) but comes in handy when using `tauri::Size` in Rust as an argument to a command, as this class automatically serializes into a valid format so it can be deserialized correctly into `tauri::Size` So instead of ```typescript import { invoke } from '@tauri-apps/api/core'; import { LogicalSize, PhysicalSize } from '@tauri-apps/api/dpi'; const size: LogicalSize | PhysicalSize = someFunction(); // where someFunction returns either LogicalSize or PhysicalSize const validSize = size instanceof LogicalSize ? { Logical: { width: size.width, height: size.height } } : { Physical: { width: size.width, height: size.height } } await invoke("do_something_with_size", { size: validSize }); ``` You can just use [`Size`](/reference/javascript/api/namespacedpi/#size) ```typescript import { invoke } from '@tauri-apps/api/core'; import { LogicalSize, PhysicalSize, Size } from '@tauri-apps/api/dpi'; const size: LogicalSize | PhysicalSize = someFunction(); // where someFunction returns either LogicalSize or PhysicalSize const validSize = new Size(size); await invoke("do_something_with_size", { size: validSize }); ``` #### Since 2.1.0 #### Constructors []() ##### new Size() ```ts new Size(size): Size ``` ###### Parameters | Parameter | Type | | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | | `size` | [`LogicalSize`](/reference/javascript/api/namespacedpi/#logicalsize) \| [`PhysicalSize`](/reference/javascript/api/namespacedpi/#physicalsize) | ###### Returns [`Size`](/reference/javascript/api/namespacedpi/#size) **Source**: #### Properties | Property | Type | Defined in | | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | | []()`size` | [`LogicalSize`](/reference/javascript/api/namespacedpi/#logicalsize) \| [`PhysicalSize`](/reference/javascript/api/namespacedpi/#physicalsize) | **Source**: | #### Methods []() ##### \_\_TAURI\_TO\_IPC\_KEY\_\_() ```ts __TAURI_TO_IPC_KEY__(): object ``` ###### Returns `object` **Source**: []() ##### toJSON() ```ts toJSON(): object ``` ###### Returns `object` **Source**: []() ##### toLogical() ```ts toLogical(scaleFactor): LogicalSize ``` ###### Parameters | Parameter | Type | | ------------- | -------- | | `scaleFactor` | `number` | ###### Returns [`LogicalSize`](/reference/javascript/api/namespacedpi/#logicalsize) **Source**: []() ##### toPhysical() ```ts toPhysical(scaleFactor): PhysicalSize ``` ###### Parameters | Parameter | Type | | ------------- | -------- | | `scaleFactor` | `number` | ###### Returns [`PhysicalSize`](/reference/javascript/api/namespacedpi/#physicalsize) **Source**: # event The event system allows you to emit events to the backend and listen to events from it. This package is also accessible with `window.__TAURI__.event` when [`app.withGlobalTauri`](https://v2.tauri.app/reference/config/#withglobaltauri) in `tauri.conf.json` is set to `true`. ## Enumerations []() ### TauriEvent #### Since 1.1.0 #### Enumeration Members []() ##### DRAG\_DROP ```ts DRAG_DROP: "tauri://drag-drop"; ``` **Source**: []() ##### DRAG\_ENTER ```ts DRAG_ENTER: "tauri://drag-enter"; ``` **Source**: []() ##### DRAG\_LEAVE ```ts DRAG_LEAVE: "tauri://drag-leave"; ``` **Source**: []() ##### DRAG\_OVER ```ts DRAG_OVER: "tauri://drag-over"; ``` **Source**: []() ##### WEBVIEW\_CREATED ```ts WEBVIEW_CREATED: "tauri://webview-created"; ``` **Source**: []() ##### WINDOW\_BLUR ```ts WINDOW_BLUR: "tauri://blur"; ``` **Source**: []() ##### WINDOW\_CLOSE\_REQUESTED ```ts WINDOW_CLOSE_REQUESTED: "tauri://close-requested"; ``` **Source**: []() ##### WINDOW\_CREATED ```ts WINDOW_CREATED: "tauri://window-created"; ``` **Source**: []() ##### WINDOW\_DESTROYED ```ts WINDOW_DESTROYED: "tauri://destroyed"; ``` **Source**: []() ##### WINDOW\_FOCUS ```ts WINDOW_FOCUS: "tauri://focus"; ``` **Source**: []() ##### WINDOW\_MOVED ```ts WINDOW_MOVED: "tauri://move"; ``` **Source**: []() ##### WINDOW\_RESIZED ```ts WINDOW_RESIZED: "tauri://resize"; ``` **Source**: []() ##### WINDOW\_RESUMED ```ts WINDOW_RESUMED: "tauri://resumed"; ``` **Source**: []() ##### WINDOW\_SCALE\_FACTOR\_CHANGED ```ts WINDOW_SCALE_FACTOR_CHANGED: "tauri://scale-change"; ``` **Source**: []() ##### WINDOW\_SUSPENDED ```ts WINDOW_SUSPENDED: "tauri://suspended"; ``` **Source**: []() ##### WINDOW\_THEME\_CHANGED ```ts WINDOW_THEME_CHANGED: "tauri://theme-changed"; ``` **Source**: ## Interfaces []() ### Event\ #### Type Parameters | Type Parameter | | -------------- | | `T` | #### Properties | Property | Type | Description | Defined in | | ------------- | ------------------------------------------------------------------ | --------------------------------- | ---------------------------------------------------------------------------------------- | | []()`event` | [`EventName`](/reference/javascript/api/namespaceevent/#eventname) | Event name | **Source**: | | []()`id` | `number` | Event identifier used to unlisten | **Source**: | | []()`payload` | `T` | Event payload | **Source**: | *** []() ### Options #### Properties | Property | Type | Description | Defined in | | ------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | | []()`target?` | `string` \| [`EventTarget`](/reference/javascript/api/namespaceevent/#eventtarget) | The event target to listen to, defaults to `{ kind: 'Any' }`, see [EventTarget](/reference/javascript/api/namespaceevent/#eventtarget). If a string is provided, EventTarget.AnyLabel is used. | **Source**: | ## Type Aliases []() ### EventCallback()\ ```ts type EventCallback: (event) => void; ``` #### Type Parameters | Type Parameter | | -------------- | | `T` | #### Parameters | Parameter | Type | | --------- | ---------------------------------------------------------------- | | `event` | [`Event`](/reference/javascript/api/namespaceevent/#eventt)<`T`> | #### Returns `void` **Source**: *** []() ### EventName ```ts type EventName: `${TauriEvent}` | string & Record; ``` **Source**: *** []() ### EventTarget ```ts type EventTarget: | object | object | object | object | object | object; ``` **Source**: *** []() ### UnlistenFn() ```ts type UnlistenFn: () => void; ``` #### Returns `void` **Source**: ## Functions []() ### emit() ```ts function emit(event, payload?): Promise ``` Emits an event to all [targets](/reference/javascript/api/namespaceevent/#eventtarget). #### Type Parameters | Type Parameter | | -------------- | | `T` | #### Parameters | Parameter | Type | Description | | ---------- | -------- | ----------------------------------------------------------------------------- | | `event` | `string` | Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`. | | `payload`? | `T` | Event payload. | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> #### Example ```typescript import { emit } from '@tauri-apps/api/event'; await emit('frontend-loaded', { loggedIn: true, token: 'authToken' }); ``` #### Since 1.0.0 **Source**: *** []() ### emitTo() ```ts function emitTo( target, event, payload?): Promise ``` Emits an event to all [targets](/reference/javascript/api/namespaceevent/#eventtarget) matching the given target. #### Type Parameters | Type Parameter | | -------------- | | `T` | #### Parameters | Parameter | Type | Description | | ---------- | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | | `target` | `string` \| [`EventTarget`](/reference/javascript/api/namespaceevent/#eventtarget) | Label of the target Window/Webview/WebviewWindow or raw [EventTarget](/reference/javascript/api/namespaceevent/#eventtarget) object. | | `event` | `string` | Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`. | | `payload`? | `T` | Event payload. | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> #### Example ```typescript import { emitTo } from '@tauri-apps/api/event'; await emitTo('main', 'frontend-loaded', { loggedIn: true, token: 'authToken' }); ``` #### Since 2.0.0 **Source**: *** []() ### listen() ```ts function listen( event, handler, options?): Promise ``` Listen to an emitted event to any [target](/reference/javascript/api/namespaceevent/#eventtarget). #### Type Parameters | Type Parameter | | -------------- | | `T` | #### Parameters | Parameter | Type | Description | | ---------- | -------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | | `event` | [`EventName`](/reference/javascript/api/namespaceevent/#eventname) | Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`. | | `handler` | [`EventCallback`](/reference/javascript/api/namespaceevent/#eventcallbackt)<`T`> | Event handler callback. | | `options`? | [`Options`](/reference/javascript/api/namespaceevent/#options) | Event listening options. | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`UnlistenFn`](/reference/javascript/api/namespaceevent/#unlistenfn)> A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted. #### Example ```typescript import { listen } from '@tauri-apps/api/event'; const unlisten = await listen('error', (event) => { console.log(`Got error, payload: ${event.payload}`); }); // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted unlisten(); ``` #### Since 1.0.0 **Source**: *** []() ### once() ```ts function once( event, handler, options?): Promise ``` Listens once to an emitted event to any [target](/reference/javascript/api/namespaceevent/#eventtarget). #### Type Parameters | Type Parameter | | -------------- | | `T` | #### Parameters | Parameter | Type | Description | | ---------- | -------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | | `event` | [`EventName`](/reference/javascript/api/namespaceevent/#eventname) | Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`. | | `handler` | [`EventCallback`](/reference/javascript/api/namespaceevent/#eventcallbackt)<`T`> | Event handler callback. | | `options`? | [`Options`](/reference/javascript/api/namespaceevent/#options) | Event listening options. | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`UnlistenFn`](/reference/javascript/api/namespaceevent/#unlistenfn)> A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted. #### Example ```typescript import { once } from '@tauri-apps/api/event'; interface LoadedPayload { loggedIn: boolean, token: string } const unlisten = await once('loaded', (event) => { console.log(`App is loaded, loggedIn: ${event.payload.loggedIn}, token: ${event.payload.token}`); }); // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted unlisten(); ``` #### Since 1.0.0 **Source**: # image ## Classes []() ### Image An RGBA Image in row-major order from top to bottom. #### Extends * [`Resource`](/reference/javascript/api/namespacecore/#resource) #### Accessors []() ##### rid ```ts get rid(): number ``` ###### Returns `number` ###### Inherited from [`Resource`](/reference/javascript/api/namespacecore/#resource).[`rid`](/reference/javascript/api/namespacecore/#rid) **Source**: #### Methods []() ##### close() ```ts close(): Promise ``` Destroys and cleans up this resource from memory. **You should not call any method on this object anymore and should drop any reference to it.** ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Inherited from [`Resource`](/reference/javascript/api/namespacecore/#resource).[`close`](/reference/javascript/api/namespacecore/#close) **Source**: []() ##### rgba() ```ts rgba(): Promise ``` Returns the RGBA data for this image, in row-major order from top to bottom. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)> **Source**: []() ##### size() ```ts size(): Promise ``` Returns the size of this image. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`ImageSize`](/reference/javascript/api/namespaceimage/#imagesize)> **Source**: []() ##### fromBytes() ```ts static fromBytes(bytes): Promise ``` Creates a new image using the provided bytes by inferring the file format. If the format is known, prefer \[@link Image.fromPngBytes] or \[@link Image.fromIcoBytes]. Only `ico` and `png` are supported (based on activated feature flag). Note that you need the `image-ico` or `image-png` Cargo features to use this API. To enable it, change your Cargo.toml file: ```toml [dependencies] tauri = { version = "...", features = ["...", "image-png"] } ``` ###### Parameters | Parameter | Type | | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `bytes` | [`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) \| `number`\[] \| [`ArrayBuffer`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Image`](/reference/javascript/api/namespaceimage/#image)> **Source**: []() ##### fromPath() ```ts static fromPath(path): Promise ``` Creates a new image using the provided path. Only `ico` and `png` are supported (based on activated feature flag). Note that you need the `image-ico` or `image-png` Cargo features to use this API. To enable it, change your Cargo.toml file: ```toml [dependencies] tauri = { version = "...", features = ["...", "image-png"] } ``` ###### Parameters | Parameter | Type | | --------- | -------- | | `path` | `string` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Image`](/reference/javascript/api/namespaceimage/#image)> **Source**: []() ##### new() ```ts static new( rgba, width, height): Promise ``` Creates a new Image using RGBA data, in row-major order from top to bottom, and with specified width and height. ###### Parameters | Parameter | Type | | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `rgba` | [`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) \| `number`\[] \| [`ArrayBuffer`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) | | `width` | `number` | | `height` | `number` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Image`](/reference/javascript/api/namespaceimage/#image)> **Source**: ## Interfaces []() ### ImageSize #### Properties | Property | Type | Defined in | | ------------ | -------- | ---------------------------------------------------------------------------------------- | | []()`height` | `number` | **Source**: | | []()`width` | `number` | **Source**: | ## Type Aliases []() ### MenuIcon ```ts type MenuIcon: | NativeIcon | string | Image | Uint8Array | ArrayBuffer | number[]; ``` A type that represents an icon that can be used in menu items. **Source**: ## Functions []() ### transformImage() ```ts function transformImage(image): T ``` Transforms image from various types into a type acceptable by Rust. See [tauri::image::JsImage](https://docs.rs/tauri/2/tauri/image/enum.JsImage.html) for more information. Note the API signature is not stable and might change. #### Type Parameters | Type Parameter | | -------------- | | `T` | #### Parameters | Parameter | Type | | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `image` | \| `null` \| `string` \| [`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) \| `number`\[] \| [`ArrayBuffer`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) \| [`Image`](/reference/javascript/api/namespaceimage/#image) | #### Returns `T` **Source**: # menu ## Enumerations []() ### NativeIcon A native Icon to be used for the menu item Platform-specific: * **Windows / Linux**: Unsupported. #### Enumeration Members []() ##### Add ```ts Add: "Add"; ``` An add item template image. **Source**: []() ##### Advanced ```ts Advanced: "Advanced"; ``` Advanced preferences toolbar icon for the preferences window. **Source**: []() ##### Bluetooth ```ts Bluetooth: "Bluetooth"; ``` A Bluetooth template image. **Source**: []() ##### Bookmarks ```ts Bookmarks: "Bookmarks"; ``` Bookmarks image suitable for a template. **Source**: []() ##### Caution ```ts Caution: "Caution"; ``` A caution image. **Source**: []() ##### ColorPanel ```ts ColorPanel: "ColorPanel"; ``` A color panel toolbar icon. **Source**: []() ##### ColumnView ```ts ColumnView: "ColumnView"; ``` A column view mode template image. **Source**: []() ##### Computer ```ts Computer: "Computer"; ``` A computer icon. **Source**: []() ##### EnterFullScreen ```ts EnterFullScreen: "EnterFullScreen"; ``` An enter full-screen mode template image. **Source**: []() ##### Everyone ```ts Everyone: "Everyone"; ``` Permissions for all users. **Source**: []() ##### ExitFullScreen ```ts ExitFullScreen: "ExitFullScreen"; ``` An exit full-screen mode template image. **Source**: []() ##### FlowView ```ts FlowView: "FlowView"; ``` A cover flow view mode template image. **Source**: []() ##### Folder ```ts Folder: "Folder"; ``` A folder image. **Source**: []() ##### FolderBurnable ```ts FolderBurnable: "FolderBurnable"; ``` A burnable folder icon. **Source**: []() ##### FolderSmart ```ts FolderSmart: "FolderSmart"; ``` A smart folder icon. **Source**: []() ##### FollowLinkFreestanding ```ts FollowLinkFreestanding: "FollowLinkFreestanding"; ``` A link template image. **Source**: []() ##### FontPanel ```ts FontPanel: "FontPanel"; ``` A font panel toolbar icon. **Source**: []() ##### GoLeft ```ts GoLeft: "GoLeft"; ``` A `go back` template image. **Source**: []() ##### GoRight ```ts GoRight: "GoRight"; ``` A `go forward` template image. **Source**: []() ##### Home ```ts Home: "Home"; ``` Home image suitable for a template. **Source**: []() ##### IChatTheater ```ts IChatTheater: "IChatTheater"; ``` An iChat Theater template image. **Source**: []() ##### IconView ```ts IconView: "IconView"; ``` An icon view mode template image. **Source**: []() ##### Info ```ts Info: "Info"; ``` An information toolbar icon. **Source**: []() ##### InvalidDataFreestanding ```ts InvalidDataFreestanding: "InvalidDataFreestanding"; ``` A template image used to denote invalid data. **Source**: []() ##### LeftFacingTriangle ```ts LeftFacingTriangle: "LeftFacingTriangle"; ``` A generic left-facing triangle template image. **Source**: []() ##### ListView ```ts ListView: "ListView"; ``` A list view mode template image. **Source**: []() ##### LockLocked ```ts LockLocked: "LockLocked"; ``` A locked padlock template image. **Source**: []() ##### LockUnlocked ```ts LockUnlocked: "LockUnlocked"; ``` An unlocked padlock template image. **Source**: []() ##### MenuMixedState ```ts MenuMixedState: "MenuMixedState"; ``` A horizontal dash, for use in menus. **Source**: []() ##### MenuOnState ```ts MenuOnState: "MenuOnState"; ``` A check mark template image, for use in menus. **Source**: []() ##### MobileMe ```ts MobileMe: "MobileMe"; ``` A MobileMe icon. **Source**: []() ##### MultipleDocuments ```ts MultipleDocuments: "MultipleDocuments"; ``` A drag image for multiple items. **Source**: []() ##### Network ```ts Network: "Network"; ``` A network icon. **Source**: []() ##### Path ```ts Path: "Path"; ``` A path button template image. **Source**: []() ##### PreferencesGeneral ```ts PreferencesGeneral: "PreferencesGeneral"; ``` General preferences toolbar icon for the preferences window. **Source**: []() ##### QuickLook ```ts QuickLook: "QuickLook"; ``` A Quick Look template image. **Source**: []() ##### Refresh ```ts Refresh: "Refresh"; ``` A refresh template image. **Source**: []() ##### RefreshFreestanding ```ts RefreshFreestanding: "RefreshFreestanding"; ``` A refresh template image. **Source**: []() ##### Remove ```ts Remove: "Remove"; ``` A remove item template image. **Source**: []() ##### RevealFreestanding ```ts RevealFreestanding: "RevealFreestanding"; ``` A reveal contents template image. **Source**: []() ##### RightFacingTriangle ```ts RightFacingTriangle: "RightFacingTriangle"; ``` A generic right-facing triangle template image. **Source**: []() ##### Share ```ts Share: "Share"; ``` A share view template image. **Source**: []() ##### Slideshow ```ts Slideshow: "Slideshow"; ``` A slideshow template image. **Source**: []() ##### SmartBadge ```ts SmartBadge: "SmartBadge"; ``` A badge for a `smart` item. **Source**: []() ##### StatusAvailable ```ts StatusAvailable: "StatusAvailable"; ``` Small green indicator, similar to iChat’s available image. **Source**: []() ##### StatusNone ```ts StatusNone: "StatusNone"; ``` Small clear indicator. **Source**: []() ##### StatusPartiallyAvailable ```ts StatusPartiallyAvailable: "StatusPartiallyAvailable"; ``` Small yellow indicator, similar to iChat’s idle image. **Source**: []() ##### StatusUnavailable ```ts StatusUnavailable: "StatusUnavailable"; ``` Small red indicator, similar to iChat’s unavailable image. **Source**: []() ##### StopProgress ```ts StopProgress: "StopProgress"; ``` A stop progress button template image. **Source**: []() ##### StopProgressFreestanding ```ts StopProgressFreestanding: "StopProgressFreestanding"; ``` A stop progress template image. **Source**: []() ##### TrashEmpty ```ts TrashEmpty: "TrashEmpty"; ``` An image of the empty trash can. **Source**: []() ##### TrashFull ```ts TrashFull: "TrashFull"; ``` An image of the full trash can. **Source**: []() ##### User ```ts User: "User"; ``` Permissions for a single user. **Source**: []() ##### UserAccounts ```ts UserAccounts: "UserAccounts"; ``` User account toolbar icon for the preferences window. **Source**: []() ##### UserGroup ```ts UserGroup: "UserGroup"; ``` Permissions for a group of users. **Source**: []() ##### UserGuest ```ts UserGuest: "UserGuest"; ``` Permissions for guests. **Source**: ## Classes []() ### CheckMenuItem A check menu item inside a [`Menu`](/reference/javascript/api/namespacemenu/#menu) or [`Submenu`](/reference/javascript/api/namespacemenu/#submenu) and usually contains a text and a check mark or a similar toggle that corresponds to a checked and unchecked states. #### Extends * `MenuItemBase` #### Accessors []() ##### id ```ts get id(): string ``` The id of this item. ###### Returns `string` ###### Inherited from `MenuItemBase.id` **Source**: []() ##### rid ```ts get rid(): number ``` ###### Returns `number` ###### Inherited from `MenuItemBase.rid` **Source**: #### Methods []() ##### close() ```ts close(): Promise ``` Destroys and cleans up this resource from memory. **You should not call any method on this object anymore and should drop any reference to it.** ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Inherited from `MenuItemBase.close` **Source**: []() ##### isChecked() ```ts isChecked(): Promise ``` Returns whether this check menu item is checked or not. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> **Source**: []() ##### isEnabled() ```ts isEnabled(): Promise ``` Returns whether this check menu item is enabled or not. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> **Source**: []() ##### setAccelerator() ```ts setAccelerator(accelerator): Promise ``` Sets the accelerator for this check menu item. ###### Parameters | Parameter | Type | | ------------- | ------------------ | | `accelerator` | `null` \| `string` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### setChecked() ```ts setChecked(checked): Promise ``` Sets whether this check menu item is checked or not. ###### Parameters | Parameter | Type | | --------- | --------- | | `checked` | `boolean` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### setEnabled() ```ts setEnabled(enabled): Promise ``` Sets whether this check menu item is enabled or not. ###### Parameters | Parameter | Type | | --------- | --------- | | `enabled` | `boolean` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### setText() ```ts setText(text): Promise ``` Sets the text for this check menu item. ###### Parameters | Parameter | Type | | --------- | -------- | | `text` | `string` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### text() ```ts text(): Promise ``` Returns the text of this check menu item. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> **Source**: []() ##### new() ```ts static new(opts): Promise ``` Create a new check menu item. ###### Parameters | Parameter | Type | | --------- | --------------------------------------------------------------------------------------- | | `opts` | [`CheckMenuItemOptions`](/reference/javascript/api/namespacemenu/#checkmenuitemoptions) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`CheckMenuItem`](/reference/javascript/api/namespacemenu/#checkmenuitem)> **Source**: *** []() ### IconMenuItem An icon menu item inside a [`Menu`](/reference/javascript/api/namespacemenu/#menu) or [`Submenu`](/reference/javascript/api/namespacemenu/#submenu) and usually contains an icon and a text. #### Extends * `MenuItemBase` #### Accessors []() ##### id ```ts get id(): string ``` The id of this item. ###### Returns `string` ###### Inherited from `MenuItemBase.id` **Source**: []() ##### rid ```ts get rid(): number ``` ###### Returns `number` ###### Inherited from `MenuItemBase.rid` **Source**: #### Methods []() ##### close() ```ts close(): Promise ``` Destroys and cleans up this resource from memory. **You should not call any method on this object anymore and should drop any reference to it.** ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Inherited from `MenuItemBase.close` **Source**: []() ##### isEnabled() ```ts isEnabled(): Promise ``` Returns whether this icon menu item is enabled or not. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> **Source**: []() ##### setAccelerator() ```ts setAccelerator(accelerator): Promise ``` Sets the accelerator for this icon menu item. ###### Parameters | Parameter | Type | | ------------- | ------------------ | | `accelerator` | `null` \| `string` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### setEnabled() ```ts setEnabled(enabled): Promise ``` Sets whether this icon menu item is enabled or not. ###### Parameters | Parameter | Type | | --------- | --------- | | `enabled` | `boolean` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### setIcon() ```ts setIcon(icon): Promise ``` Sets an icon for this icon menu item ###### Parameters | Parameter | Type | | --------- | -------------------------------------------------------------------------- | | `icon` | `null` \| [`MenuIcon`](/reference/javascript/api/namespaceimage/#menuicon) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### setText() ```ts setText(text): Promise ``` Sets the text for this icon menu item. ###### Parameters | Parameter | Type | | --------- | -------- | | `text` | `string` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### text() ```ts text(): Promise ``` Returns the text of this icon menu item. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> **Source**: []() ##### new() ```ts static new(opts): Promise ``` Create a new icon menu item. ###### Parameters | Parameter | Type | | --------- | ------------------------------------------------------------------------------------- | | `opts` | [`IconMenuItemOptions`](/reference/javascript/api/namespacemenu/#iconmenuitemoptions) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`IconMenuItem`](/reference/javascript/api/namespacemenu/#iconmenuitem)> **Source**: *** []() ### Menu A type that is either a menu bar on the window on Windows and Linux or as a global menu in the menubar on macOS. Platform-specific: * **macOS**: if using [`Menu`](/reference/javascript/api/namespacemenu/#menu) for the global menubar, it can only contain [`Submenu`](/reference/javascript/api/namespacemenu/#submenu)s. #### Extends * `MenuItemBase` #### Accessors []() ##### id ```ts get id(): string ``` The id of this item. ###### Returns `string` ###### Inherited from `MenuItemBase.id` **Source**: []() ##### rid ```ts get rid(): number ``` ###### Returns `number` ###### Inherited from `MenuItemBase.rid` **Source**: #### Methods []() ##### append() ```ts append(items): Promise ``` Add a menu item to the end of this menu. Platform-specific: * **macOS:** Only [`Submenu`](/reference/javascript/api/namespacemenu/#submenu)s can be added to a [`Menu`](/reference/javascript/api/namespacemenu/#menu). ###### Type Parameters | Type Parameter | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `T` *extends* \| [`MenuItemOptions`](/reference/javascript/api/namespacemenu/#menuitemoptions) \| [`MenuItem`](/reference/javascript/api/namespacemenu/#menuitem) \| [`SubmenuOptions`](/reference/javascript/api/namespacemenu/#submenuoptions) \| [`PredefinedMenuItemOptions`](/reference/javascript/api/namespacemenu/#predefinedmenuitemoptions) \| [`CheckMenuItemOptions`](/reference/javascript/api/namespacemenu/#checkmenuitemoptions) \| [`IconMenuItemOptions`](/reference/javascript/api/namespacemenu/#iconmenuitemoptions) \| [`PredefinedMenuItem`](/reference/javascript/api/namespacemenu/#predefinedmenuitem) \| [`Submenu`](/reference/javascript/api/namespacemenu/#submenu) \| [`CheckMenuItem`](/reference/javascript/api/namespacemenu/#checkmenuitem) \| [`IconMenuItem`](/reference/javascript/api/namespacemenu/#iconmenuitem) | ###### Parameters | Parameter | Type | | --------- | ------------- | | `items` | `T` \| `T`\[] | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### close() ```ts close(): Promise ``` Destroys and cleans up this resource from memory. **You should not call any method on this object anymore and should drop any reference to it.** ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Inherited from `MenuItemBase.close` **Source**: []() ##### get() ```ts get(id): Promise< | null | MenuItem | PredefinedMenuItem | Submenu | CheckMenuItem | IconMenuItem> ``` Retrieves the menu item matching the given identifier. ###### Parameters | Parameter | Type | | --------- | -------- | | `id` | `string` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)< | `null` | [`MenuItem`](/reference/javascript/api/namespacemenu/#menuitem) | [`PredefinedMenuItem`](/reference/javascript/api/namespacemenu/#predefinedmenuitem) | [`Submenu`](/reference/javascript/api/namespacemenu/#submenu) | [`CheckMenuItem`](/reference/javascript/api/namespacemenu/#checkmenuitem) | [`IconMenuItem`](/reference/javascript/api/namespacemenu/#iconmenuitem)> **Source**: []() ##### insert() ```ts insert(items, position): Promise ``` Add a menu item to the specified position in this menu. Platform-specific: * **macOS:** Only [`Submenu`](/reference/javascript/api/namespacemenu/#submenu)s can be added to a [`Menu`](/reference/javascript/api/namespacemenu/#menu). ###### Type Parameters | Type Parameter | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `T` *extends* \| [`MenuItemOptions`](/reference/javascript/api/namespacemenu/#menuitemoptions) \| [`MenuItem`](/reference/javascript/api/namespacemenu/#menuitem) \| [`SubmenuOptions`](/reference/javascript/api/namespacemenu/#submenuoptions) \| [`PredefinedMenuItemOptions`](/reference/javascript/api/namespacemenu/#predefinedmenuitemoptions) \| [`CheckMenuItemOptions`](/reference/javascript/api/namespacemenu/#checkmenuitemoptions) \| [`IconMenuItemOptions`](/reference/javascript/api/namespacemenu/#iconmenuitemoptions) \| [`PredefinedMenuItem`](/reference/javascript/api/namespacemenu/#predefinedmenuitem) \| [`Submenu`](/reference/javascript/api/namespacemenu/#submenu) \| [`CheckMenuItem`](/reference/javascript/api/namespacemenu/#checkmenuitem) \| [`IconMenuItem`](/reference/javascript/api/namespacemenu/#iconmenuitem) | ###### Parameters | Parameter | Type | | ---------- | ------------- | | `items` | `T` \| `T`\[] | | `position` | `number` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### items() ```ts items(): Promise<( | MenuItem | PredefinedMenuItem | Submenu | CheckMenuItem | IconMenuItem)[]> ``` Returns a list of menu items that has been added to this menu. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<( | [`MenuItem`](/reference/javascript/api/namespacemenu/#menuitem) | [`PredefinedMenuItem`](/reference/javascript/api/namespacemenu/#predefinedmenuitem) | [`Submenu`](/reference/javascript/api/namespacemenu/#submenu) | [`CheckMenuItem`](/reference/javascript/api/namespacemenu/#checkmenuitem) | [`IconMenuItem`](/reference/javascript/api/namespacemenu/#iconmenuitem))\[]> **Source**: []() ##### popup() ```ts popup(at?, window?): Promise ``` Popup this menu as a context menu on the specified window. ###### Parameters | Parameter | Type | Description | | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `at`? | [`LogicalPosition`](/reference/javascript/api/namespacedpi/#logicalposition) \| [`PhysicalPosition`](/reference/javascript/api/namespacedpi/#physicalposition) \| [`Position`](/reference/javascript/api/namespacedpi/#position) | If a position is provided, it is relative to the window’s top-left corner. If there isn’t one provided, the menu will pop up at the current location of the mouse. | | `window`? | [`Window`](/reference/javascript/api/namespacewindow/#window) | - | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### prepend() ```ts prepend(items): Promise ``` Add a menu item to the beginning of this menu. Platform-specific: * **macOS:** Only [`Submenu`](/reference/javascript/api/namespacemenu/#submenu)s can be added to a [`Menu`](/reference/javascript/api/namespacemenu/#menu). ###### Type Parameters | Type Parameter | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `T` *extends* \| [`MenuItemOptions`](/reference/javascript/api/namespacemenu/#menuitemoptions) \| [`MenuItem`](/reference/javascript/api/namespacemenu/#menuitem) \| [`SubmenuOptions`](/reference/javascript/api/namespacemenu/#submenuoptions) \| [`PredefinedMenuItemOptions`](/reference/javascript/api/namespacemenu/#predefinedmenuitemoptions) \| [`CheckMenuItemOptions`](/reference/javascript/api/namespacemenu/#checkmenuitemoptions) \| [`IconMenuItemOptions`](/reference/javascript/api/namespacemenu/#iconmenuitemoptions) \| [`PredefinedMenuItem`](/reference/javascript/api/namespacemenu/#predefinedmenuitem) \| [`Submenu`](/reference/javascript/api/namespacemenu/#submenu) \| [`CheckMenuItem`](/reference/javascript/api/namespacemenu/#checkmenuitem) \| [`IconMenuItem`](/reference/javascript/api/namespacemenu/#iconmenuitem) | ###### Parameters | Parameter | Type | | --------- | ------------- | | `items` | `T` \| `T`\[] | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### remove() ```ts remove(item): Promise ``` Remove a menu item from this menu. ###### Parameters | Parameter | Type | | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `item` | \| [`MenuItem`](/reference/javascript/api/namespacemenu/#menuitem) \| [`PredefinedMenuItem`](/reference/javascript/api/namespacemenu/#predefinedmenuitem) \| [`Submenu`](/reference/javascript/api/namespacemenu/#submenu) \| [`CheckMenuItem`](/reference/javascript/api/namespacemenu/#checkmenuitem) \| [`IconMenuItem`](/reference/javascript/api/namespacemenu/#iconmenuitem) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### removeAt() ```ts removeAt(position): Promise< | null | MenuItem | PredefinedMenuItem | Submenu | CheckMenuItem | IconMenuItem> ``` Remove a menu item from this menu at the specified position. ###### Parameters | Parameter | Type | | ---------- | -------- | | `position` | `number` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)< | `null` | [`MenuItem`](/reference/javascript/api/namespacemenu/#menuitem) | [`PredefinedMenuItem`](/reference/javascript/api/namespacemenu/#predefinedmenuitem) | [`Submenu`](/reference/javascript/api/namespacemenu/#submenu) | [`CheckMenuItem`](/reference/javascript/api/namespacemenu/#checkmenuitem) | [`IconMenuItem`](/reference/javascript/api/namespacemenu/#iconmenuitem)> **Source**: []() ##### setAsAppMenu() ```ts setAsAppMenu(): Promise ``` Sets the app-wide menu and returns the previous one. If a window was not created with an explicit menu or had one set explicitly, this menu will be assigned to it. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`null` | [`Menu`](/reference/javascript/api/namespacemenu/#menu)> **Source**: []() ##### setAsWindowMenu() ```ts setAsWindowMenu(window?): Promise ``` Sets the window menu and returns the previous one. Platform-specific: * **macOS:** Unsupported. The menu on macOS is app-wide and not specific to one window, if you need to set it, use [`Menu.setAsAppMenu`](/reference/javascript/api/namespacemenu/#setasappmenu) instead. ###### Parameters | Parameter | Type | | --------- | ------------------------------------------------------------- | | `window`? | [`Window`](/reference/javascript/api/namespacewindow/#window) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`null` | [`Menu`](/reference/javascript/api/namespacemenu/#menu)> **Source**: []() ##### default() ```ts static default(): Promise ``` Create a default menu. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Menu`](/reference/javascript/api/namespacemenu/#menu)> **Source**: []() ##### new() ```ts static new(opts?): Promise ``` Create a new menu. ###### Parameters | Parameter | Type | | --------- | --------------------------------------------------------------------- | | `opts`? | [`MenuOptions`](/reference/javascript/api/namespacemenu/#menuoptions) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Menu`](/reference/javascript/api/namespacemenu/#menu)> **Source**: *** []() ### MenuItem A menu item inside a [`Menu`](/reference/javascript/api/namespacemenu/#menu) or [`Submenu`](/reference/javascript/api/namespacemenu/#submenu) and contains only text. #### Extends * `MenuItemBase` #### Accessors []() ##### id ```ts get id(): string ``` The id of this item. ###### Returns `string` ###### Inherited from `MenuItemBase.id` **Source**: []() ##### rid ```ts get rid(): number ``` ###### Returns `number` ###### Inherited from `MenuItemBase.rid` **Source**: #### Methods []() ##### close() ```ts close(): Promise ``` Destroys and cleans up this resource from memory. **You should not call any method on this object anymore and should drop any reference to it.** ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Inherited from `MenuItemBase.close` **Source**: []() ##### isEnabled() ```ts isEnabled(): Promise ``` Returns whether this menu item is enabled or not. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> **Source**: []() ##### setAccelerator() ```ts setAccelerator(accelerator): Promise ``` Sets the accelerator for this menu item. ###### Parameters | Parameter | Type | | ------------- | ------------------ | | `accelerator` | `null` \| `string` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### setEnabled() ```ts setEnabled(enabled): Promise ``` Sets whether this menu item is enabled or not. ###### Parameters | Parameter | Type | | --------- | --------- | | `enabled` | `boolean` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### setText() ```ts setText(text): Promise ``` Sets the text for this menu item. ###### Parameters | Parameter | Type | | --------- | -------- | | `text` | `string` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### text() ```ts text(): Promise ``` Returns the text of this menu item. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> **Source**: []() ##### new() ```ts static new(opts): Promise ``` Create a new menu item. ###### Parameters | Parameter | Type | | --------- | ----------------------------------------------------------------------------- | | `opts` | [`MenuItemOptions`](/reference/javascript/api/namespacemenu/#menuitemoptions) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`MenuItem`](/reference/javascript/api/namespacemenu/#menuitem)> **Source**: *** []() ### PredefinedMenuItem A predefined (native) menu item which has a predefined behavior by the OS or by tauri. #### Extends * `MenuItemBase` #### Accessors []() ##### id ```ts get id(): string ``` The id of this item. ###### Returns `string` ###### Inherited from `MenuItemBase.id` **Source**: []() ##### rid ```ts get rid(): number ``` ###### Returns `number` ###### Inherited from `MenuItemBase.rid` **Source**: #### Methods []() ##### close() ```ts close(): Promise ``` Destroys and cleans up this resource from memory. **You should not call any method on this object anymore and should drop any reference to it.** ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Inherited from `MenuItemBase.close` **Source**: []() ##### setText() ```ts setText(text): Promise ``` Sets the text for this predefined menu item. ###### Parameters | Parameter | Type | | --------- | -------- | | `text` | `string` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### text() ```ts text(): Promise ``` Returns the text of this predefined menu item. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> **Source**: []() ##### new() ```ts static new(opts?): Promise ``` Create a new predefined menu item. ###### Parameters | Parameter | Type | | --------- | ------------------------------------------------------------------------------------------------- | | `opts`? | [`PredefinedMenuItemOptions`](/reference/javascript/api/namespacemenu/#predefinedmenuitemoptions) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`PredefinedMenuItem`](/reference/javascript/api/namespacemenu/#predefinedmenuitem)> **Source**: *** []() ### Submenu A type that is a submenu inside a [`Menu`](/reference/javascript/api/namespacemenu/#menu) or [`Submenu`](/reference/javascript/api/namespacemenu/#submenu). #### Extends * `MenuItemBase` #### Accessors []() ##### id ```ts get id(): string ``` The id of this item. ###### Returns `string` ###### Inherited from `MenuItemBase.id` **Source**: []() ##### rid ```ts get rid(): number ``` ###### Returns `number` ###### Inherited from `MenuItemBase.rid` **Source**: #### Methods []() ##### append() ```ts append(items): Promise ``` Add a menu item to the end of this submenu. Platform-specific: * **macOS:** Only [`Submenu`](/reference/javascript/api/namespacemenu/#submenu)s can be added to a [`Menu`](/reference/javascript/api/namespacemenu/#menu). ###### Type Parameters | Type Parameter | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `T` *extends* \| [`MenuItemOptions`](/reference/javascript/api/namespacemenu/#menuitemoptions) \| [`MenuItem`](/reference/javascript/api/namespacemenu/#menuitem) \| [`SubmenuOptions`](/reference/javascript/api/namespacemenu/#submenuoptions) \| [`PredefinedMenuItemOptions`](/reference/javascript/api/namespacemenu/#predefinedmenuitemoptions) \| [`CheckMenuItemOptions`](/reference/javascript/api/namespacemenu/#checkmenuitemoptions) \| [`IconMenuItemOptions`](/reference/javascript/api/namespacemenu/#iconmenuitemoptions) \| [`PredefinedMenuItem`](/reference/javascript/api/namespacemenu/#predefinedmenuitem) \| [`Submenu`](/reference/javascript/api/namespacemenu/#submenu) \| [`CheckMenuItem`](/reference/javascript/api/namespacemenu/#checkmenuitem) \| [`IconMenuItem`](/reference/javascript/api/namespacemenu/#iconmenuitem) | ###### Parameters | Parameter | Type | | --------- | ------------- | | `items` | `T` \| `T`\[] | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### close() ```ts close(): Promise ``` Destroys and cleans up this resource from memory. **You should not call any method on this object anymore and should drop any reference to it.** ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Inherited from `MenuItemBase.close` **Source**: []() ##### get() ```ts get(id): Promise< | null | MenuItem | PredefinedMenuItem | Submenu | CheckMenuItem | IconMenuItem> ``` Retrieves the menu item matching the given identifier. ###### Parameters | Parameter | Type | | --------- | -------- | | `id` | `string` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)< | `null` | [`MenuItem`](/reference/javascript/api/namespacemenu/#menuitem) | [`PredefinedMenuItem`](/reference/javascript/api/namespacemenu/#predefinedmenuitem) | [`Submenu`](/reference/javascript/api/namespacemenu/#submenu) | [`CheckMenuItem`](/reference/javascript/api/namespacemenu/#checkmenuitem) | [`IconMenuItem`](/reference/javascript/api/namespacemenu/#iconmenuitem)> **Source**: []() ##### insert() ```ts insert(items, position): Promise ``` Add a menu item to the specified position in this submenu. Platform-specific: * **macOS:** Only [`Submenu`](/reference/javascript/api/namespacemenu/#submenu)s can be added to a [`Menu`](/reference/javascript/api/namespacemenu/#menu). ###### Type Parameters | Type Parameter | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `T` *extends* \| [`MenuItemOptions`](/reference/javascript/api/namespacemenu/#menuitemoptions) \| [`MenuItem`](/reference/javascript/api/namespacemenu/#menuitem) \| [`SubmenuOptions`](/reference/javascript/api/namespacemenu/#submenuoptions) \| [`PredefinedMenuItemOptions`](/reference/javascript/api/namespacemenu/#predefinedmenuitemoptions) \| [`CheckMenuItemOptions`](/reference/javascript/api/namespacemenu/#checkmenuitemoptions) \| [`IconMenuItemOptions`](/reference/javascript/api/namespacemenu/#iconmenuitemoptions) \| [`PredefinedMenuItem`](/reference/javascript/api/namespacemenu/#predefinedmenuitem) \| [`Submenu`](/reference/javascript/api/namespacemenu/#submenu) \| [`CheckMenuItem`](/reference/javascript/api/namespacemenu/#checkmenuitem) \| [`IconMenuItem`](/reference/javascript/api/namespacemenu/#iconmenuitem) | ###### Parameters | Parameter | Type | | ---------- | ------------- | | `items` | `T` \| `T`\[] | | `position` | `number` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### isEnabled() ```ts isEnabled(): Promise ``` Returns whether this submenu is enabled or not. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> **Source**: []() ##### items() ```ts items(): Promise<( | MenuItem | PredefinedMenuItem | Submenu | CheckMenuItem | IconMenuItem)[]> ``` Returns a list of menu items that has been added to this submenu. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<( | [`MenuItem`](/reference/javascript/api/namespacemenu/#menuitem) | [`PredefinedMenuItem`](/reference/javascript/api/namespacemenu/#predefinedmenuitem) | [`Submenu`](/reference/javascript/api/namespacemenu/#submenu) | [`CheckMenuItem`](/reference/javascript/api/namespacemenu/#checkmenuitem) | [`IconMenuItem`](/reference/javascript/api/namespacemenu/#iconmenuitem))\[]> **Source**: []() ##### popup() ```ts popup(at?, window?): Promise ``` Popup this submenu as a context menu on the specified window. If the position, is provided, it is relative to the window’s top-left corner. ###### Parameters | Parameter | Type | | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `at`? | [`LogicalPosition`](/reference/javascript/api/namespacedpi/#logicalposition) \| [`PhysicalPosition`](/reference/javascript/api/namespacedpi/#physicalposition) | | `window`? | [`Window`](/reference/javascript/api/namespacewindow/#window) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### prepend() ```ts prepend(items): Promise ``` Add a menu item to the beginning of this submenu. Platform-specific: * **macOS:** Only [`Submenu`](/reference/javascript/api/namespacemenu/#submenu)s can be added to a [`Menu`](/reference/javascript/api/namespacemenu/#menu). ###### Type Parameters | Type Parameter | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `T` *extends* \| [`MenuItemOptions`](/reference/javascript/api/namespacemenu/#menuitemoptions) \| [`MenuItem`](/reference/javascript/api/namespacemenu/#menuitem) \| [`SubmenuOptions`](/reference/javascript/api/namespacemenu/#submenuoptions) \| [`PredefinedMenuItemOptions`](/reference/javascript/api/namespacemenu/#predefinedmenuitemoptions) \| [`CheckMenuItemOptions`](/reference/javascript/api/namespacemenu/#checkmenuitemoptions) \| [`IconMenuItemOptions`](/reference/javascript/api/namespacemenu/#iconmenuitemoptions) \| [`PredefinedMenuItem`](/reference/javascript/api/namespacemenu/#predefinedmenuitem) \| [`Submenu`](/reference/javascript/api/namespacemenu/#submenu) \| [`CheckMenuItem`](/reference/javascript/api/namespacemenu/#checkmenuitem) \| [`IconMenuItem`](/reference/javascript/api/namespacemenu/#iconmenuitem) | ###### Parameters | Parameter | Type | | --------- | ------------- | | `items` | `T` \| `T`\[] | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### remove() ```ts remove(item): Promise ``` Remove a menu item from this submenu. ###### Parameters | Parameter | Type | | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `item` | \| [`MenuItem`](/reference/javascript/api/namespacemenu/#menuitem) \| [`PredefinedMenuItem`](/reference/javascript/api/namespacemenu/#predefinedmenuitem) \| [`Submenu`](/reference/javascript/api/namespacemenu/#submenu) \| [`CheckMenuItem`](/reference/javascript/api/namespacemenu/#checkmenuitem) \| [`IconMenuItem`](/reference/javascript/api/namespacemenu/#iconmenuitem) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### removeAt() ```ts removeAt(position): Promise< | null | MenuItem | PredefinedMenuItem | Submenu | CheckMenuItem | IconMenuItem> ``` Remove a menu item from this submenu at the specified position. ###### Parameters | Parameter | Type | | ---------- | -------- | | `position` | `number` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)< | `null` | [`MenuItem`](/reference/javascript/api/namespacemenu/#menuitem) | [`PredefinedMenuItem`](/reference/javascript/api/namespacemenu/#predefinedmenuitem) | [`Submenu`](/reference/javascript/api/namespacemenu/#submenu) | [`CheckMenuItem`](/reference/javascript/api/namespacemenu/#checkmenuitem) | [`IconMenuItem`](/reference/javascript/api/namespacemenu/#iconmenuitem)> **Source**: []() ##### setAsHelpMenuForNSApp() ```ts setAsHelpMenuForNSApp(): Promise ``` Set this submenu as the Help menu for the application on macOS. This will cause macOS to automatically add a search box to the menu. If no menu is set as the Help menu, macOS will automatically use any menu which has a title matching the localized word “Help”. Platform-specific: * **Windows / Linux**: Unsupported. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### setAsWindowsMenuForNSApp() ```ts setAsWindowsMenuForNSApp(): Promise ``` Set this submenu as the Window menu for the application on macOS. This will cause macOS to automatically add window-switching items and certain other items to the menu. Platform-specific: * **Windows / Linux**: Unsupported. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### setEnabled() ```ts setEnabled(enabled): Promise ``` Sets whether this submenu is enabled or not. ###### Parameters | Parameter | Type | | --------- | --------- | | `enabled` | `boolean` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### setIcon() ```ts setIcon(icon): Promise ``` Sets an icon for this submenu ###### Parameters | Parameter | Type | | --------- | -------------------------------------------------------------------------- | | `icon` | `null` \| [`MenuIcon`](/reference/javascript/api/namespaceimage/#menuicon) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### setText() ```ts setText(text): Promise ``` Sets the text for this submenu. ###### Parameters | Parameter | Type | | --------- | -------- | | `text` | `string` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### text() ```ts text(): Promise ``` Returns the text of this submenu. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> **Source**: []() ##### new() ```ts static new(opts): Promise ``` Create a new submenu. ###### Parameters | Parameter | Type | | --------- | --------------------------------------------------------------------------- | | `opts` | [`SubmenuOptions`](/reference/javascript/api/namespacemenu/#submenuoptions) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Submenu`](/reference/javascript/api/namespacemenu/#submenu)> **Source**: ## Interfaces []() ### AboutMetadata A metadata for the about predefined menu item. #### Properties | Property | Type | Description | Defined in | | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------- | | []()`authors?` | `string`\[] | The authors of the application. Platform-specific - **macOS:** Unsupported. | **Source**: | | []()`comments?` | `string` | Application comments. Platform-specific - **macOS:** Unsupported. | **Source**: | | []()`copyright?` | `string` | The copyright of the application. | **Source**: | | []()`credits?` | `string` | The credits. Platform-specific - **Windows / Linux:** Unsupported. | **Source**: | | []()`icon?` | \| `string` \| [`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) \| `number`\[] \| [`ArrayBuffer`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) \| [`Image`](/reference/javascript/api/namespaceimage/#image) | The application icon. Platform-specific - **Windows:** Unsupported. | **Source**: | | []()`license?` | `string` | The license of the application. Platform-specific - **macOS:** Unsupported. | **Source**: | | []()`name?` | `string` | Sets the application name. | **Source**: | | []()`shortVersion?` | `string` | The short version, e.g. “1.0”. Platform-specific - **Windows / Linux:** Appended to the end of `version` in parentheses. | **Source**: | | []()`version?` | `string` | The application version. | **Source**: | | []()`website?` | `string` | The application website. Platform-specific - **macOS:** Unsupported. | **Source**: | | []()`websiteLabel?` | `string` | The website label. Platform-specific - **macOS:** Unsupported. | **Source**: | *** []() ### CheckMenuItemOptions Options for creating a new check menu item. #### Extends * [`MenuItemOptions`](/reference/javascript/api/namespacemenu/#menuitemoptions) #### Properties | Property | Type | Description | Inherited from | Defined in | | ------------------ | -------------------------- | ---------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | []()`accelerator?` | `string` | Specify an accelerator for the new menu item. | [`MenuItemOptions`](/reference/javascript/api/namespacemenu/#menuitemoptions).[`accelerator`](/reference/javascript/api/namespacemenu/#accelerator-2) | **Source**: | | []()`action?` | (`id`: `string`) => `void` | Specify a handler to be called when this menu item is activated. | [`MenuItemOptions`](/reference/javascript/api/namespacemenu/#menuitemoptions).[`action`](/reference/javascript/api/namespacemenu/#action-2) | **Source**: | | []()`checked?` | `boolean` | Whether the new check menu item is enabled or not. | - | **Source**: | | []()`enabled?` | `boolean` | Whether the new menu item is enabled or not. | [`MenuItemOptions`](/reference/javascript/api/namespacemenu/#menuitemoptions).[`enabled`](/reference/javascript/api/namespacemenu/#enabled-2) | **Source**: | | []()`id?` | `string` | Specify an id to use for the new menu item. | [`MenuItemOptions`](/reference/javascript/api/namespacemenu/#menuitemoptions).[`id`](/reference/javascript/api/namespacemenu/#id-8) | **Source**: | | []()`text` | `string` | The text of the new menu item. | [`MenuItemOptions`](/reference/javascript/api/namespacemenu/#menuitemoptions).[`text`](/reference/javascript/api/namespacemenu/#text-7) | **Source**: | *** []() ### IconMenuItemOptions Options for creating a new icon menu item. #### Extends * [`MenuItemOptions`](/reference/javascript/api/namespacemenu/#menuitemoptions) #### Properties | Property | Type | Description | Inherited from | Defined in | | ------------------ | ---------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | []()`accelerator?` | `string` | Specify an accelerator for the new menu item. | [`MenuItemOptions`](/reference/javascript/api/namespacemenu/#menuitemoptions).[`accelerator`](/reference/javascript/api/namespacemenu/#accelerator-2) | **Source**: | | []()`action?` | (`id`: `string`) => `void` | Specify a handler to be called when this menu item is activated. | [`MenuItemOptions`](/reference/javascript/api/namespacemenu/#menuitemoptions).[`action`](/reference/javascript/api/namespacemenu/#action-2) | **Source**: | | []()`enabled?` | `boolean` | Whether the new menu item is enabled or not. | [`MenuItemOptions`](/reference/javascript/api/namespacemenu/#menuitemoptions).[`enabled`](/reference/javascript/api/namespacemenu/#enabled-2) | **Source**: | | []()`icon?` | [`MenuIcon`](/reference/javascript/api/namespaceimage/#menuicon) | Icon to be used for the new icon menu item. Note that you may need the `image-ico` or `image-png` Cargo features to use this API. To enable it, change your Cargo.toml file: `[dependencies] tauri = { version = "...", features = ["...", "image-png"] }` | - | **Source**: | | []()`id?` | `string` | Specify an id to use for the new menu item. | [`MenuItemOptions`](/reference/javascript/api/namespacemenu/#menuitemoptions).[`id`](/reference/javascript/api/namespacemenu/#id-8) | **Source**: | | []()`text` | `string` | The text of the new menu item. | [`MenuItemOptions`](/reference/javascript/api/namespacemenu/#menuitemoptions).[`text`](/reference/javascript/api/namespacemenu/#text-7) | **Source**: | *** []() ### MenuItemOptions Options for creating a new menu item. #### Extended by * [`CheckMenuItemOptions`](/reference/javascript/api/namespacemenu/#checkmenuitemoptions) * [`IconMenuItemOptions`](/reference/javascript/api/namespacemenu/#iconmenuitemoptions) #### Properties | Property | Type | Description | Defined in | | ------------------ | -------------------------- | ---------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ | | []()`accelerator?` | `string` | Specify an accelerator for the new menu item. | **Source**: | | []()`action?` | (`id`: `string`) => `void` | Specify a handler to be called when this menu item is activated. | **Source**: | | []()`enabled?` | `boolean` | Whether the new menu item is enabled or not. | **Source**: | | []()`id?` | `string` | Specify an id to use for the new menu item. | **Source**: | | []()`text` | `string` | The text of the new menu item. | **Source**: | *** []() ### MenuOptions Options for creating a new menu. #### Properties | Property | Type | Description | Defined in | | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------- | -------------------------------------------------------------------------------------------- | | []()`id?` | `string` | Specify an id to use for the new menu. | **Source**: | | []()`items?` | ( \| [`MenuItemOptions`](/reference/javascript/api/namespacemenu/#menuitemoptions) \| [`MenuItem`](/reference/javascript/api/namespacemenu/#menuitem) \| [`SubmenuOptions`](/reference/javascript/api/namespacemenu/#submenuoptions) \| [`PredefinedMenuItemOptions`](/reference/javascript/api/namespacemenu/#predefinedmenuitemoptions) \| [`CheckMenuItemOptions`](/reference/javascript/api/namespacemenu/#checkmenuitemoptions) \| [`IconMenuItemOptions`](/reference/javascript/api/namespacemenu/#iconmenuitemoptions) \| [`PredefinedMenuItem`](/reference/javascript/api/namespacemenu/#predefinedmenuitem) \| [`Submenu`](/reference/javascript/api/namespacemenu/#submenu) \| [`CheckMenuItem`](/reference/javascript/api/namespacemenu/#checkmenuitem) \| [`IconMenuItem`](/reference/javascript/api/namespacemenu/#iconmenuitem))\[] | List of items to add to the new menu. | **Source**: | *** []() ### PredefinedMenuItemOptions Options for creating a new predefined menu item. #### Properties | Property | Type | Description | Defined in | | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------- | ---------------------------------------------------------------------------------------------------------- | | []()`item` | \| `object` \| `"Separator"` \| `"Copy"` \| `"Cut"` \| `"Paste"` \| `"SelectAll"` \| `"Undo"` \| `"Redo"` \| `"Minimize"` \| `"Maximize"` \| `"Fullscreen"` \| `"Hide"` \| `"HideOthers"` \| `"ShowAll"` \| `"CloseWindow"` \| `"Quit"` \| `"Services"` \| `"BringAllToFront"` | The predefined item type | **Source**: | | []()`text?` | `string` | The text of the new predefined menu item. | **Source**: | ## Type Aliases []() ### SubmenuOptions ```ts type SubmenuOptions: Omit & MenuOptions & object; ``` #### Type declaration | Name | Type | Description | Defined in | | ------ | ---------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------- | | `icon` | [`MenuIcon`](/reference/javascript/api/namespaceimage/#menuicon) | Icon to be used for the submenu. Note: you may need the `image-ico` or `image-png` Cargo features to use this API. | **Source**: | **Source**: # mocks ## Interfaces []() ### MockIPCOptions Options for `mockIPC`. # Options `shouldMockEvents`: If true, the `listen` and `emit` functions will be mocked, allowing you to test event handling without a real backend. **This will consume any events emitted with the `plugin:event` prefix.** #### Since 2.7.0 #### Properties | Property | Type | Defined in | | ----------------------- | --------- | ---------------------------------------------------------------------------------------- | | []()`shouldMockEvents?` | `boolean` | **Source**: | ## Functions []() ### clearMocks() ```ts function clearMocks(): void ``` Clears mocked functions/data injected by the other functions in this module. When using a test runner that doesn’t provide a fresh window object for each test, calling this function will reset tauri specific properties. # Example ```js import { mockWindows, clearMocks } from "@tauri-apps/api/mocks" afterEach(() => { clearMocks() }) test("mocked windows", () => { mockWindows("main", "second", "third"); expect(window.__TAURI_INTERNALS__).toHaveProperty("metadata") }) test("no mocked windows", () => { expect(window.__TAURI_INTERNALS__).not.toHaveProperty("metadata") }) ``` #### Returns `void` #### Since 1.0.0 **Source**: *** []() ### mockConvertFileSrc() ```ts function mockConvertFileSrc(osName): void ``` Mock `convertFileSrc` function #### Parameters | Parameter | Type | Description | | --------- | -------- | -------------------------------------------------------------------- | | `osName` | `string` | The operating system to mock, can be one of linux, macos, or windows | #### Returns `void` #### Example ```js import { mockConvertFileSrc } from "@tauri-apps/api/mocks"; import { convertFileSrc } from "@tauri-apps/api/core"; mockConvertFileSrc("windows") const url = convertFileSrc("C:\\Users\\user\\file.txt") ``` #### Since 1.6.0 **Source**: *** []() ### mockIPC() ```ts function mockIPC(cb, options?): void ``` Intercepts all IPC requests with the given mock handler. This function can be used when testing tauri frontend applications or when running the frontend in a Node.js context during static site generation. # Examples Testing setup using Vitest: ```ts import { mockIPC, clearMocks } from "@tauri-apps/api/mocks" import { invoke } from "@tauri-apps/api/core" afterEach(() => { clearMocks() }) test("mocked command", () => { mockIPC((cmd, payload) => { switch (cmd) { case "add": return (payload.a as number) + (payload.b as number); default: break; } }); expect(invoke('add', { a: 12, b: 15 })).resolves.toBe(27); }) ``` The callback function can also return a Promise: ```js import { mockIPC, clearMocks } from "@tauri-apps/api/mocks" import { invoke } from "@tauri-apps/api/core" afterEach(() => { clearMocks() }) test("mocked command", () => { mockIPC((cmd, payload) => { if(cmd === "get_data") { return fetch("https://example.com/data.json") .then((response) => response.json()) } }); expect(invoke('get_data')).resolves.toBe({ foo: 'bar' }); }) ``` `listen` can also be mocked with direct calls to the `emit` function. This functionality is opt-in via the `shouldMockEvents` option: ```js import { mockIPC, clearMocks } from "@tauri-apps/api/mocks" import { emit, listen } from "@tauri-apps/api/event" afterEach(() => { clearMocks() }) test("mocked event", () => { mockIPC(() => {}, { shouldMockEvents: true }); // enable event mocking const eventHandler = vi.fn(); listen('test-event', eventHandler); // typically in component setup or similar emit('test-event', { foo: 'bar' }); expect(eventHandler).toHaveBeenCalledWith({ event: 'test-event', payload: { foo: 'bar' } }); }) ``` `emitTo` is currently **not** supported by this mock implementation. #### Parameters | Parameter | Type | | ---------- | ---------------------------------------------------------------------------- | | `cb` | (`cmd`, `payload`?) => `unknown` | | `options`? | [`MockIPCOptions`](/reference/javascript/api/namespacemocks/#mockipcoptions) | #### Returns `void` #### Since 1.0.0 **Source**: *** []() ### mockWindows() ```ts function mockWindows(current, ..._additionalWindows): void ``` Mocks one or many window labels. In non-tauri context it is required to call this function *before* using the `@tauri-apps/api/window` module. This function only mocks the *presence* of windows, window properties (e.g. width and height) can be mocked like regular IPC calls using the `mockIPC` function. # Examples ```js import { mockWindows } from "@tauri-apps/api/mocks"; import { getCurrentWindow } from "@tauri-apps/api/window"; mockWindows("main", "second", "third"); const win = getCurrentWindow(); win.label // "main" ``` ```js import { mockWindows } from "@tauri-apps/api/mocks"; mockWindows("main", "second", "third"); mockIPC((cmd, args) => { if (cmd === "plugin:event|emit") { console.log('emit event', args?.event, args?.payload); } }); const { emit } = await import("@tauri-apps/api/event"); await emit('loaded'); // this will cause the mocked IPC handler to log to the console. ``` #### Parameters | Parameter | Type | Description | | --------------------- | ----------- | ------------------------------------------------------ | | `current` | `string` | Label of window this JavaScript context is running in. | | …`_additionalWindows` | `string`\[] | - | #### Returns `void` #### Since 1.0.0 **Source**: # path The path module provides utilities for working with file and directory paths. This package is also accessible with `window.__TAURI__.path` when [`app.withGlobalTauri`](https://v2.tauri.app/reference/config/#withglobaltauri) in `tauri.conf.json` is set to `true`. It is recommended to allowlist only the APIs you use for optimal bundle size and security. ## Enumerations []() ### BaseDirectory #### Since 2.0.0 #### Enumeration Members []() ##### AppCache ```ts AppCache: 16; ``` ###### See [appCacheDir](/reference/javascript/api/namespacepath/#appcachedir) for more information. **Source**: []() ##### AppConfig ```ts AppConfig: 13; ``` ###### See [appConfigDir](/reference/javascript/api/namespacepath/#appconfigdir) for more information. **Source**: []() ##### AppData ```ts AppData: 14; ``` ###### See [appDataDir](/reference/javascript/api/namespacepath/#appdatadir) for more information. **Source**: []() ##### AppLocalData ```ts AppLocalData: 15; ``` ###### See [appLocalDataDir](/reference/javascript/api/namespacepath/#applocaldatadir) for more information. **Source**: []() ##### AppLog ```ts AppLog: 17; ``` ###### See [appLogDir](/reference/javascript/api/namespacepath/#applogdir) for more information. **Source**: []() ##### Audio ```ts Audio: 1; ``` ###### See [audioDir](/reference/javascript/api/namespacepath/#audiodir) for more information. **Source**: []() ##### Cache ```ts Cache: 2; ``` ###### See [cacheDir](/reference/javascript/api/namespacepath/#cachedir) for more information. **Source**: []() ##### Config ```ts Config: 3; ``` ###### See [configDir](/reference/javascript/api/namespacepath/#configdir) for more information. **Source**: []() ##### Data ```ts Data: 4; ``` ###### See [dataDir](/reference/javascript/api/namespacepath/#datadir) for more information. **Source**: []() ##### Desktop ```ts Desktop: 18; ``` ###### See [desktopDir](/reference/javascript/api/namespacepath/#desktopdir) for more information. **Source**: []() ##### Document ```ts Document: 6; ``` ###### See [documentDir](/reference/javascript/api/namespacepath/#documentdir) for more information. **Source**: []() ##### Download ```ts Download: 7; ``` ###### See [downloadDir](/reference/javascript/api/namespacepath/#downloaddir) for more information. **Source**: []() ##### Executable ```ts Executable: 19; ``` ###### See [executableDir](/reference/javascript/api/namespacepath/#executabledir) for more information. **Source**: []() ##### Font ```ts Font: 20; ``` ###### See [fontDir](/reference/javascript/api/namespacepath/#fontdir) for more information. **Source**: []() ##### Home ```ts Home: 21; ``` ###### See [homeDir](/reference/javascript/api/namespacepath/#homedir) for more information. **Source**: []() ##### LocalData ```ts LocalData: 5; ``` ###### See [localDataDir](/reference/javascript/api/namespacepath/#localdatadir) for more information. **Source**: []() ##### Picture ```ts Picture: 8; ``` ###### See [pictureDir](/reference/javascript/api/namespacepath/#picturedir) for more information. **Source**: []() ##### Public ```ts Public: 9; ``` ###### See [publicDir](/reference/javascript/api/namespacepath/#publicdir) for more information. **Source**: []() ##### Resource ```ts Resource: 11; ``` ###### See [resourceDir](/reference/javascript/api/namespacepath/#resourcedir) for more information. **Source**: []() ##### Runtime ```ts Runtime: 22; ``` ###### See [runtimeDir](/reference/javascript/api/namespacepath/#runtimedir) for more information. **Source**: []() ##### Temp ```ts Temp: 12; ``` ###### See [tempDir](/reference/javascript/api/namespacepath/#tempdir) for more information. **Source**: []() ##### Template ```ts Template: 23; ``` ###### See [templateDir](/reference/javascript/api/namespacepath/#templatedir) for more information. **Source**: []() ##### Video ```ts Video: 10; ``` ###### See [videoDir](/reference/javascript/api/namespacepath/#videodir) for more information. **Source**: ## Functions []() ### appCacheDir() ```ts function appCacheDir(): Promise ``` Returns the path to the suggested directory for your app’s cache files. Resolves to `${cacheDir}/${bundleIdentifier}`, where `bundleIdentifier` is the [`identifier`](https://v2.tauri.app/reference/config/#identifier) value configured in `tauri.conf.json`. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> #### Example ```typescript import { appCacheDir } from '@tauri-apps/api/path'; const appCacheDirPath = await appCacheDir(); ``` #### Since 1.2.0 **Source**: *** []() ### appConfigDir() ```ts function appConfigDir(): Promise ``` Returns the path to the suggested directory for your app’s config files. Resolves to `${configDir}/${bundleIdentifier}`, where `bundleIdentifier` is the [`identifier`](https://v2.tauri.app/reference/config/#identifier) value configured in `tauri.conf.json`. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> #### Example ```typescript import { appConfigDir } from '@tauri-apps/api/path'; const appConfigDirPath = await appConfigDir(); ``` #### Since 1.2.0 **Source**: *** []() ### appDataDir() ```ts function appDataDir(): Promise ``` Returns the path to the suggested directory for your app’s data files. Resolves to `${dataDir}/${bundleIdentifier}`, where `bundleIdentifier` is the [`identifier`](https://v2.tauri.app/reference/config/#identifier) value configured in `tauri.conf.json`. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> #### Example ```typescript import { appDataDir } from '@tauri-apps/api/path'; const appDataDirPath = await appDataDir(); ``` #### Since 1.2.0 **Source**: *** []() ### appLocalDataDir() ```ts function appLocalDataDir(): Promise ``` Returns the path to the suggested directory for your app’s local data files. Resolves to `${localDataDir}/${bundleIdentifier}`, where `bundleIdentifier` is the [`identifier`](https://v2.tauri.app/reference/config/#identifier) value configured in `tauri.conf.json`. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> #### Example ```typescript import { appLocalDataDir } from '@tauri-apps/api/path'; const appLocalDataDirPath = await appLocalDataDir(); ``` #### Since 1.2.0 **Source**: *** []() ### appLogDir() ```ts function appLogDir(): Promise ``` Returns the path to the suggested directory for your app’s log files. Platform-specific * **Linux:** Resolves to `${configDir}/${bundleIdentifier}/logs`. * **macOS:** Resolves to `${homeDir}/Library/Logs/{bundleIdentifier}` * **Windows:** Resolves to `${configDir}/${bundleIdentifier}/logs`. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> #### Example ```typescript import { appLogDir } from '@tauri-apps/api/path'; const appLogDirPath = await appLogDir(); ``` #### Since 1.2.0 **Source**: *** []() ### audioDir() ```ts function audioDir(): Promise ``` Returns the path to the user’s audio directory. Platform-specific * **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)’ `XDG_MUSIC_DIR`. * **macOS:** Resolves to `$HOME/Music`. * **Windows:** Resolves to `{FOLDERID_Music}`. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> #### Example ```typescript import { audioDir } from '@tauri-apps/api/path'; const audioDirPath = await audioDir(); ``` #### Since 1.0.0 **Source**: *** []() ### basename() ```ts function basename(path, ext?): Promise ``` Returns the last portion of a `path`. Trailing directory separators are ignored. #### Parameters | Parameter | Type | Description | | --------- | -------- | ---------------------------------------------------------------- | | `path` | `string` | - | | `ext`? | `string` | An optional file extension to be removed from the returned path. | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> #### Example ```typescript import { basename } from '@tauri-apps/api/path'; const base = await basename('path/to/app.conf'); assert(base === 'app.conf'); ``` #### Since 1.0.0 **Source**: *** []() ### cacheDir() ```ts function cacheDir(): Promise ``` Returns the path to the user’s cache directory. Platform-specific * **Linux:** Resolves to `$XDG_CACHE_HOME` or `$HOME/.cache`. * **macOS:** Resolves to `$HOME/Library/Caches`. * **Windows:** Resolves to `{FOLDERID_LocalAppData}`. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> #### Example ```typescript import { cacheDir } from '@tauri-apps/api/path'; const cacheDirPath = await cacheDir(); ``` #### Since 1.0.0 **Source**: *** []() ### configDir() ```ts function configDir(): Promise ``` Returns the path to the user’s config directory. Platform-specific * **Linux:** Resolves to `$XDG_CONFIG_HOME` or `$HOME/.config`. * **macOS:** Resolves to `$HOME/Library/Application Support`. * **Windows:** Resolves to `{FOLDERID_RoamingAppData}`. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> #### Example ```typescript import { configDir } from '@tauri-apps/api/path'; const configDirPath = await configDir(); ``` #### Since 1.0.0 **Source**: *** []() ### dataDir() ```ts function dataDir(): Promise ``` Returns the path to the user’s data directory. Platform-specific * **Linux:** Resolves to `$XDG_DATA_HOME` or `$HOME/.local/share`. * **macOS:** Resolves to `$HOME/Library/Application Support`. * **Windows:** Resolves to `{FOLDERID_RoamingAppData}`. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> #### Example ```typescript import { dataDir } from '@tauri-apps/api/path'; const dataDirPath = await dataDir(); ``` #### Since 1.0.0 **Source**: *** []() ### delimiter() ```ts function delimiter(): string ``` Returns the platform-specific path segment delimiter: * `;` on Windows * `:` on POSIX #### Returns `string` #### Since 2.0.0 **Source**: *** []() ### desktopDir() ```ts function desktopDir(): Promise ``` Returns the path to the user’s desktop directory. Platform-specific * **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)’ `XDG_DESKTOP_DIR`. * **macOS:** Resolves to `$HOME/Desktop`. * **Windows:** Resolves to `{FOLDERID_Desktop}`. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> #### Example ```typescript import { desktopDir } from '@tauri-apps/api/path'; const desktopPath = await desktopDir(); ``` #### Since 1.0.0 **Source**: *** []() ### dirname() ```ts function dirname(path): Promise ``` Returns the parent directory of a given `path`. Trailing directory separators are ignored. #### Parameters | Parameter | Type | | --------- | -------- | | `path` | `string` | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> #### Example ```typescript import { dirname } from '@tauri-apps/api/path'; const dir = await dirname('/path/to/somedir/'); assert(dir === '/path/to'); ``` #### Since 1.0.0 **Source**: *** []() ### documentDir() ```ts function documentDir(): Promise ``` Returns the path to the user’s document directory. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> #### Example ```typescript import { documentDir } from '@tauri-apps/api/path'; const documentDirPath = await documentDir(); ``` Platform-specific * **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)’ `XDG_DOCUMENTS_DIR`. * **macOS:** Resolves to `$HOME/Documents`. * **Windows:** Resolves to `{FOLDERID_Documents}`. #### Since 1.0.0 **Source**: *** []() ### downloadDir() ```ts function downloadDir(): Promise ``` Returns the path to the user’s download directory. Platform-specific * **Linux**: Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)’ `XDG_DOWNLOAD_DIR`. * **macOS**: Resolves to `$HOME/Downloads`. * **Windows**: Resolves to `{FOLDERID_Downloads}`. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> #### Example ```typescript import { downloadDir } from '@tauri-apps/api/path'; const downloadDirPath = await downloadDir(); ``` #### Since 1.0.0 **Source**: *** []() ### executableDir() ```ts function executableDir(): Promise ``` Returns the path to the user’s executable directory. Platform-specific * **Linux:** Resolves to `$XDG_BIN_HOME/../bin` or `$XDG_DATA_HOME/../bin` or `$HOME/.local/bin`. * **macOS:** Not supported. * **Windows:** Not supported. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> #### Example ```typescript import { executableDir } from '@tauri-apps/api/path'; const executableDirPath = await executableDir(); ``` #### Since 1.0.0 **Source**: *** []() ### extname() ```ts function extname(path): Promise ``` Returns the extension of the `path`. #### Parameters | Parameter | Type | | --------- | -------- | | `path` | `string` | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> #### Example ```typescript import { extname } from '@tauri-apps/api/path'; const ext = await extname('/path/to/file.html'); assert(ext === 'html'); ``` #### Since 1.0.0 **Source**: *** []() ### fontDir() ```ts function fontDir(): Promise ``` Returns the path to the user’s font directory. Platform-specific * **Linux:** Resolves to `$XDG_DATA_HOME/fonts` or `$HOME/.local/share/fonts`. * **macOS:** Resolves to `$HOME/Library/Fonts`. * **Windows:** Not supported. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> #### Example ```typescript import { fontDir } from '@tauri-apps/api/path'; const fontDirPath = await fontDir(); ``` #### Since 1.0.0 **Source**: *** []() ### homeDir() ```ts function homeDir(): Promise ``` Returns the path to the user’s home directory. Platform-specific * **Linux:** Resolves to `$HOME`. * **macOS:** Resolves to `$HOME`. * **Windows:** Resolves to `{FOLDERID_Profile}`. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> #### Example ```typescript import { homeDir } from '@tauri-apps/api/path'; const homeDirPath = await homeDir(); ``` #### Since 1.0.0 **Source**: *** []() ### isAbsolute() ```ts function isAbsolute(path): Promise ``` Returns whether the path is absolute or not. #### Parameters | Parameter | Type | | --------- | -------- | | `path` | `string` | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> #### Example ```typescript import { isAbsolute } from '@tauri-apps/api/path'; assert(await isAbsolute('/home/tauri')); ``` #### Since 1.0.0 **Source**: *** []() ### join() ```ts function join(...paths): Promise ``` Joins all given `path` segments together using the platform-specific separator as a delimiter, then normalizes the resulting path. #### Parameters | Parameter | Type | | --------- | ----------- | | …`paths` | `string`\[] | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> #### Example ```typescript import { join, appDataDir } from '@tauri-apps/api/path'; const appDataDirPath = await appDataDir(); const path = await join(appDataDirPath, 'users', 'tauri', 'avatar.png'); ``` #### Since 1.0.0 **Source**: *** []() ### localDataDir() ```ts function localDataDir(): Promise ``` Returns the path to the user’s local data directory. Platform-specific * **Linux:** Resolves to `$XDG_DATA_HOME` or `$HOME/.local/share`. * **macOS:** Resolves to `$HOME/Library/Application Support`. * **Windows:** Resolves to `{FOLDERID_LocalAppData}`. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> #### Example ```typescript import { localDataDir } from '@tauri-apps/api/path'; const localDataDirPath = await localDataDir(); ``` #### Since 1.0.0 **Source**: *** []() ### normalize() ```ts function normalize(path): Promise ``` Normalizes the given `path`, resolving `'..'` and `'.'` segments and resolve symbolic links. #### Parameters | Parameter | Type | | --------- | -------- | | `path` | `string` | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> #### Example ```typescript import { normalize, appDataDir } from '@tauri-apps/api/path'; const appDataDirPath = await appDataDir(); const path = await normalize(`${appDataDirPath}/../users/tauri/avatar.png`); ``` #### Since 1.0.0 **Source**: *** []() ### pictureDir() ```ts function pictureDir(): Promise ``` Returns the path to the user’s picture directory. Platform-specific * **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)’ `XDG_PICTURES_DIR`. * **macOS:** Resolves to `$HOME/Pictures`. * **Windows:** Resolves to `{FOLDERID_Pictures}`. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> #### Example ```typescript import { pictureDir } from '@tauri-apps/api/path'; const pictureDirPath = await pictureDir(); ``` #### Since 1.0.0 **Source**: *** []() ### publicDir() ```ts function publicDir(): Promise ``` Returns the path to the user’s public directory. Platform-specific * **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)’ `XDG_PUBLICSHARE_DIR`. * **macOS:** Resolves to `$HOME/Public`. * **Windows:** Resolves to `{FOLDERID_Public}`. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> #### Example ```typescript import { publicDir } from '@tauri-apps/api/path'; const publicDirPath = await publicDir(); ``` #### Since 1.0.0 **Source**: *** []() ### resolve() ```ts function resolve(...paths): Promise ``` Resolves a sequence of `paths` or `path` segments into an absolute path. #### Parameters | Parameter | Type | | --------- | ----------- | | …`paths` | `string`\[] | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> #### Example ```typescript import { resolve, appDataDir } from '@tauri-apps/api/path'; const appDataDirPath = await appDataDir(); const path = await resolve(appDataDirPath, '..', 'users', 'tauri', 'avatar.png'); ``` #### Since 1.0.0 **Source**: *** []() ### resolveResource() ```ts function resolveResource(resourcePath): Promise ``` Resolve the path to a resource file. #### Parameters | Parameter | Type | Description | | -------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `resourcePath` | `string` | The path to the resource. Must follow the same syntax as defined in `tauri.conf.json > bundle > resources`, i.e. keeping subfolders and parent dir components (`../`). | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> The full path to the resource. #### Example ```typescript import { resolveResource } from '@tauri-apps/api/path'; const resourcePath = await resolveResource('script.sh'); ``` #### Since 1.0.0 **Source**: *** []() ### resourceDir() ```ts function resourceDir(): Promise ``` Returns the path to the application’s resource directory. To resolve a resource path, see [`resolveResource`](/reference/javascript/api/namespacepath/#resolveresource). ## Platform-specific Although we provide the exact path where this function resolves to, this is not a contract and things might change in the future * **Windows:** Resolves to the directory that contains the main executable. * **Linux:** When running in an AppImage, the `APPDIR` variable will be set to the mounted location of the app, and the resource dir will be `${APPDIR}/usr/lib/${exe_name}`. If not running in an AppImage, the path is `/usr/lib/${exe_name}`. When running the app from `src-tauri/target/(debug|release)/`, the path is `${exe_dir}/../lib/${exe_name}`. * **macOS:** Resolves to `${exe_dir}/../Resources` (inside .app). * **iOS:** Resolves to `${exe_dir}/assets`. * **Android:** Currently the resources are stored in the APK as assets so it’s not a normal file system path, we return a special URI prefix `asset://localhost/` here that can be used with the [file system plugin](https://tauri.app/plugin/file-system/), #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> #### Example ```typescript import { resourceDir } from '@tauri-apps/api/path'; const resourceDirPath = await resourceDir(); ``` #### Since 1.0.0 **Source**: *** []() ### runtimeDir() ```ts function runtimeDir(): Promise ``` Returns the path to the user’s runtime directory. Platform-specific * **Linux:** Resolves to `$XDG_RUNTIME_DIR`. * **macOS:** Not supported. * **Windows:** Not supported. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> #### Example ```typescript import { runtimeDir } from '@tauri-apps/api/path'; const runtimeDirPath = await runtimeDir(); ``` #### Since 1.0.0 **Source**: *** []() ### sep() ```ts function sep(): string ``` Returns the platform-specific path segment separator: * `\` on Windows * `/` on POSIX #### Returns `string` #### Since 2.0.0 **Source**: *** []() ### tempDir() ```ts function tempDir(): Promise ``` Returns a temporary directory. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> #### Example ```typescript import { tempDir } from '@tauri-apps/api/path'; const temp = await tempDir(); ``` #### Since 2.0.0 **Source**: *** []() ### templateDir() ```ts function templateDir(): Promise ``` Returns the path to the user’s template directory. Platform-specific * **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)’ `XDG_TEMPLATES_DIR`. * **macOS:** Not supported. * **Windows:** Resolves to `{FOLDERID_Templates}`. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> #### Example ```typescript import { templateDir } from '@tauri-apps/api/path'; const templateDirPath = await templateDir(); ``` #### Since 1.0.0 **Source**: *** []() ### videoDir() ```ts function videoDir(): Promise ``` Returns the path to the user’s video directory. Platform-specific * **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)’ `XDG_VIDEOS_DIR`. * **macOS:** Resolves to `$HOME/Movies`. * **Windows:** Resolves to `{FOLDERID_Videos}`. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> #### Example ```typescript import { videoDir } from '@tauri-apps/api/path'; const videoDirPath = await videoDir(); ``` #### Since 1.0.0 **Source**: # tray ## Classes []() ### TrayIcon Tray icon class and associated methods. This type constructor is private, instead, you should use the static method [`TrayIcon.new`](/reference/javascript/api/namespacetray/#new). #### Warning Unlike Rust, javascript does not have any way to run cleanup code when an object is being removed by garbage collection, but this tray icon will be cleaned up when the tauri app exists, however if you want to cleanup this object early, you need to call [`TrayIcon.close`](/reference/javascript/api/namespacecore/#close). #### Example ```ts import { TrayIcon } from '@tauri-apps/api/tray'; const tray = await TrayIcon.new({ tooltip: 'awesome tray tooltip' }); tray.set_tooltip('new tooltip'); ``` #### Extends * [`Resource`](/reference/javascript/api/namespacecore/#resource) #### Properties | Property | Modifier | Type | Description | Defined in | | -------- | -------- | -------- | -------------------------------------- | ---------------------------------------------------------------------------------------- | | []()`id` | `public` | `string` | The id associated with this tray icon. | **Source**: | #### Accessors []() ##### rid ```ts get rid(): number ``` ###### Returns `number` ###### Inherited from [`Resource`](/reference/javascript/api/namespacecore/#resource).[`rid`](/reference/javascript/api/namespacecore/#rid) **Source**: #### Methods []() ##### close() ```ts close(): Promise ``` Destroys and cleans up this resource from memory. **You should not call any method on this object anymore and should drop any reference to it.** ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Inherited from [`Resource`](/reference/javascript/api/namespacecore/#resource).[`close`](/reference/javascript/api/namespacecore/#close) **Source**: []() ##### setIcon() ```ts setIcon(icon): Promise ``` Sets a new tray icon. If `null` is provided, it will remove the icon. Note that you may need the `image-ico` or `image-png` Cargo features to use this API. To enable it, change your Cargo.toml file: ```toml [dependencies] tauri = { version = "...", features = ["...", "image-png"] } ``` ###### Parameters | Parameter | Type | | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `icon` | \| `null` \| `string` \| [`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) \| `number`\[] \| [`ArrayBuffer`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) \| [`Image`](/reference/javascript/api/namespaceimage/#image) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### setIconAsTemplate() ```ts setIconAsTemplate(asTemplate): Promise ``` Sets the current icon as a [template](https://developer.apple.com/documentation/appkit/nsimage/1520017-template?language=objc). **macOS only** ###### Parameters | Parameter | Type | | ------------ | --------- | | `asTemplate` | `boolean` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### setIconWithAsTemplate() ```ts setIconWithAsTemplate(icon, asTemplate): Promise ``` Sets a new tray icon and template status atomically. **macOS only**. Note that you may need the `image-ico` or `image-png` Cargo features to use this API. To enable it, change your Cargo.toml file: ```toml [dependencies] tauri = { version = "...", features = ["...", "image-png"] } ``` ###### Parameters | Parameter | Type | | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `icon` | \| `null` \| `string` \| [`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) \| `number`\[] \| [`ArrayBuffer`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) \| [`Image`](/reference/javascript/api/namespaceimage/#image) | | `asTemplate` | `boolean` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### setMenu() ```ts setMenu(menu): Promise ``` Sets a new tray menu. Platform-specific: * **Linux**: once a menu is set it cannot be removed so `null` has no effect ###### Parameters | Parameter | Type | | --------- | ---------------------------------------------------------------------------------------------------------------------------------- | | `menu` | `null` \| [`Submenu`](/reference/javascript/api/namespacemenu/#submenu) \| [`Menu`](/reference/javascript/api/namespacemenu/#menu) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### ~~setMenuOnLeftClick()~~ ```ts setMenuOnLeftClick(onLeft): Promise ``` Disable or enable showing the tray menu on left click. Platform-specific: * **Linux**: Unsupported. ###### Parameters | Parameter | Type | | --------- | --------- | | `onLeft` | `boolean` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Deprecated use [`TrayIcon.setShowMenuOnLeftClick`](/reference/javascript/api/namespacetray/#setshowmenuonleftclick) instead. **Source**: []() ##### setShowMenuOnLeftClick() ```ts setShowMenuOnLeftClick(onLeft): Promise ``` Disable or enable showing the tray menu on left click. Platform-specific: * **Linux**: Unsupported. ###### Parameters | Parameter | Type | | --------- | --------- | | `onLeft` | `boolean` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Since 2.2.0 **Source**: []() ##### setTempDirPath() ```ts setTempDirPath(path): Promise ``` Sets the tray icon temp dir path. **Linux only**. On Linux, we need to write the icon to the disk and usually it will be `$XDG_RUNTIME_DIR/tray-icon` or `$TEMP/tray-icon`. ###### Parameters | Parameter | Type | | --------- | ------------------ | | `path` | `null` \| `string` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### setTitle() ```ts setTitle(title): Promise ``` Sets the tooltip for this tray icon. Platform-specific: * **Linux:** The title will not be shown unless there is an icon as well. The title is useful for numerical and other frequently updated information. In general, it shouldn’t be shown unless a user requests it as it can take up a significant amount of space on the user’s panel. This may not be shown in all visualizations. * **Windows:** Unsupported ###### Parameters | Parameter | Type | | --------- | ------------------ | | `title` | `null` \| `string` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### setTooltip() ```ts setTooltip(tooltip): Promise ``` Sets the tooltip for this tray icon. Platform-specific: * **Linux:** Unsupported ###### Parameters | Parameter | Type | | --------- | ------------------ | | `tooltip` | `null` \| `string` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### setVisible() ```ts setVisible(visible): Promise ``` Show or hide this tray icon. ###### Parameters | Parameter | Type | | --------- | --------- | | `visible` | `boolean` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### getById() ```ts static getById(id): Promise ``` Gets a tray icon using the provided id. ###### Parameters | Parameter | Type | | --------- | -------- | | `id` | `string` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`null` | [`TrayIcon`](/reference/javascript/api/namespacetray/#trayicon)> **Source**: []() ##### new() ```ts static new(options?): Promise ``` Creates a new [`TrayIcon`](/reference/javascript/api/namespacetray/#trayicon) Platform-specific: * **Linux:** Sometimes the icon won’t be visible unless a menu is set. Setting an empty [`Menu`](/reference/javascript/api/namespacemenu/#menu) is enough. ###### Parameters | Parameter | Type | | ---------- | ----------------------------------------------------------------------------- | | `options`? | [`TrayIconOptions`](/reference/javascript/api/namespacetray/#trayiconoptions) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`TrayIcon`](/reference/javascript/api/namespacetray/#trayicon)> **Source**: []() ##### removeById() ```ts static removeById(id): Promise ``` Removes a tray icon using the provided id from tauri’s internal state. Note that this may cause the tray icon to disappear if it wasn’t cloned somewhere else or referenced by JS. ###### Parameters | Parameter | Type | | --------- | -------- | | `id` | `string` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: ## Interfaces []() ### TrayIconOptions [`TrayIcon`](/reference/javascript/api/namespacetray/#new) creation options #### Properties | Property | Type | Description | Defined in | | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------- | | []()`action?` | (`event`: [`TrayIconEvent`](/reference/javascript/api/namespacetray/#trayiconevent)) => `void` | A handler for an event on the tray icon. | **Source**: | | []()`icon?` | \| `string` \| [`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) \| `number`\[] \| [`ArrayBuffer`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) \| [`Image`](/reference/javascript/api/namespaceimage/#image) | The tray icon which could be icon bytes or path to the icon file. Note that you may need the `image-ico` or `image-png` Cargo features to use this API. To enable it, change your Cargo.toml file: `[dependencies] tauri = { version = "...", features = ["...", "image-png"] }` | **Source**: | | []()`iconAsTemplate?` | `boolean` | Use the icon as a [template](https://developer.apple.com/documentation/appkit/nsimage/1520017-template?language=objc). **macOS only**. | **Source**: | | []()`id?` | `string` | The tray icon id. If undefined, a random one will be assigned | **Source**: | | []()`menu?` | [`Submenu`](/reference/javascript/api/namespacemenu/#submenu) \| [`Menu`](/reference/javascript/api/namespacemenu/#menu) | The tray icon menu | **Source**: | | []()~~`menuOnLeftClick?`~~ | `boolean` | Whether to show the tray menu on left click or not, default is `true`. Platform-specific: - **Linux**: Unsupported. **Deprecated** use [`TrayIconOptions.showMenuOnLeftClick`](/reference/javascript/api/namespacetray/#showmenuonleftclick) instead. | **Source**: | | []()`showMenuOnLeftClick?` | `boolean` | Whether to show the tray menu on left click or not, default is `true`. Platform-specific: - **Linux**: Unsupported. **Since** 2.2.0 | **Source**: | | []()`tempDirPath?` | `string` | The tray icon temp dir path. **Linux only**. On Linux, we need to write the icon to the disk and usually it will be `$XDG_RUNTIME_DIR/tray-icon` or `$TEMP/tray-icon`. | **Source**: | | []()`title?` | `string` | The tray title Platform-specific - **Linux:** The title will not be shown unless there is an icon as well. The title is useful for numerical and other frequently updated information. In general, it shouldn’t be shown unless a user requests it as it can take up a significant amount of space on the user’s panel. This may not be shown in all visualizations. - **Windows:** Unsupported. | **Source**: | | []()`tooltip?` | `string` | The tray icon tooltip | **Source**: | ## Type Aliases []() ### MouseButton ```ts type MouseButton: "Left" | "Right" | "Middle"; ``` **Source**: *** []() ### MouseButtonState ```ts type MouseButtonState: "Up" | "Down"; ``` **Source**: *** []() ### TrayIconClickEvent ```ts type TrayIconClickEvent: object; ``` #### Type declaration | Name | Type | Description | Defined in | | ------------- | ------------------------------------------------------------------------------- | ------------------------------------------------- | --------------------------------------------------------------------------------------- | | `button` | [`MouseButton`](/reference/javascript/api/namespacetray/#mousebutton) | Mouse button that triggered this event. | **Source**: | | `buttonState` | [`MouseButtonState`](/reference/javascript/api/namespacetray/#mousebuttonstate) | Mouse button state when this event was triggered. | **Source**: | **Source**: *** []() ### TrayIconEvent ```ts type TrayIconEvent: | TrayIconEventBase<"Click"> & TrayIconClickEvent | TrayIconEventBase<"DoubleClick"> & Omit | TrayIconEventBase<"Enter"> | TrayIconEventBase<"Move"> | TrayIconEventBase<"Leave">; ``` Describes a tray icon event. Platform-specific: * **Linux**: Unsupported. The event is not emitted even though the icon is shown, the icon will still show a context menu on right click. **Source**: *** []() ### TrayIconEventBase\ ```ts type TrayIconEventBase: object; ``` #### Type Parameters | Type Parameter | | ----------------------------------------------------------------------------------------------- | | `T` *extends* [`TrayIconEventType`](/reference/javascript/api/namespacetray/#trayiconeventtype) | #### Type declaration | Name | Type | Description | Defined in | | --------------- | ------------------------------------------------------------------------------ | -------------------------------------------------------- | --------------------------------------------------------------------------------------- | | `id` | `string` | Id of the tray icon which triggered this event. | **Source**: | | `position` | [`PhysicalPosition`](/reference/javascript/api/namespacedpi/#physicalposition) | Physical position of the click the triggered this event. | **Source**: | | `rect` | `object` | Position and size of the tray icon. | **Source**: | | `rect.position` | [`PhysicalPosition`](/reference/javascript/api/namespacedpi/#physicalposition) | - | **Source**: | | `rect.size` | [`PhysicalSize`](/reference/javascript/api/namespacedpi/#physicalsize) | - | **Source**: | | `type` | `T` | The tray icon event type | **Source**: | **Source**: *** []() ### TrayIconEventType ```ts type TrayIconEventType: | "Click" | "DoubleClick" | "Enter" | "Move" | "Leave"; ``` **Source**: # webview Provides APIs to create webviews, communicate with other webviews and manipulate the current webview. #### Webview events Events can be listened to using [Webview.listen](/reference/javascript/api/namespacewebview/#listen): ```typescript import { getCurrentWebview } from "@tauri-apps/api/webview"; getCurrentWebview().listen("my-webview-event", ({ event, payload }) => { }); ``` ## Classes []() ### Webview Create new webview or get a handle to an existing one. Webviews are identified by a *label* a unique identifier that can be used to reference it later. It may only contain alphanumeric characters `a-zA-Z` plus the following special characters `-`, `/`, `:` and `_`. #### Example ```typescript import { Window } from "@tauri-apps/api/window" import { Webview } from "@tauri-apps/api/webview" const appWindow = new Window('uniqueLabel'); appWindow.once('tauri://created', async function () { // `new Webview` Should be called after the window is successfully created, // or webview may not be attached to the window since window is not created yet. // loading embedded asset: const webview = new Webview(appWindow, 'theUniqueLabel', { url: 'path/to/page.html', // create a webview with specific logical position and size x: 0, y: 0, width: 800, height: 600, }); // alternatively, load a remote URL: const webview = new Webview(appWindow, 'theUniqueLabel', { url: 'https://github.com/tauri-apps/tauri', // create a webview with specific logical position and size x: 0, y: 0, width: 800, height: 600, }); webview.once('tauri://created', function () { // webview successfully created }); webview.once('tauri://error', function (e) { // an error happened creating the webview }); // emit an event to the backend await webview.emit("some-event", "data"); // listen to an event from the backend const unlisten = await webview.listen("event-name", e => { }); unlisten(); }); ``` #### Since 2.0.0 #### Extended by * [`WebviewWindow`](/reference/javascript/api/namespacewebviewwindow/#webviewwindow) #### Constructors []() ##### new Webview() ```ts new Webview( window, label, options): Webview ``` Creates a new Webview. ###### Parameters | Parameter | Type | Description | | --------- | ------------------------------------------------------------------------------ | ------------------------------------------------------------- | | `window` | [`Window`](/reference/javascript/api/namespacewindow/#window) | the window to add this webview to. | | `label` | `string` | The unique webview label. Must be alphanumeric: `a-zA-Z-/:_`. | | `options` | [`WebviewOptions`](/reference/javascript/api/namespacewebview/#webviewoptions) | - | ###### Returns [`Webview`](/reference/javascript/api/namespacewebview/#webview) The [Webview](/reference/javascript/api/namespacewebview/#webview) instance to communicate with the webview. ###### Example ```typescript import { Window } from '@tauri-apps/api/window' import { Webview } from '@tauri-apps/api/webview' const appWindow = new Window('my-label') appWindow.once('tauri://created', async function() { const webview = new Webview(appWindow, 'my-label', { url: 'https://github.com/tauri-apps/tauri', // create a webview with specific logical position and size x: 0, y: 0, width: 800, height: 600, }); webview.once('tauri://created', function () { // webview successfully created }); webview.once('tauri://error', function (e) { // an error happened creating the webview }); }); ``` **Source**: #### Properties | Property | Type | Description | Defined in | | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------- | | []()`label` | `string` | The webview label. It is a unique identifier for the webview, can be used to reference it later. | **Source**: | | []()`listeners` | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)<`string`, [`EventCallback`](/reference/javascript/api/namespaceevent/#eventcallbackt)<`any`>\[]> | Local event listeners. | **Source**: | | []()`window` | [`Window`](/reference/javascript/api/namespacewindow/#window) | The window hosting this webview. | **Source**: | #### Methods []() ##### clearAllBrowsingData() ```ts clearAllBrowsingData(): Promise ``` Clears all browsing data for this webview. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWebview } from '@tauri-apps/api/webview'; await getCurrentWebview().clearAllBrowsingData(); ``` **Source**: []() ##### close() ```ts close(): Promise ``` Closes the webview. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWebview } from '@tauri-apps/api/webview'; await getCurrentWebview().close(); ``` **Source**: []() ##### emit() ```ts emit(event, payload?): Promise ``` Emits an event to all [targets](/reference/javascript/api/namespaceevent/#eventtarget). ###### Type Parameters | Type Parameter | | -------------- | | `T` | ###### Parameters | Parameter | Type | Description | | ---------- | -------- | ----------------------------------------------------------------------------- | | `event` | `string` | Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`. | | `payload`? | `T` | Event payload. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Example ```typescript import { getCurrentWebview } from '@tauri-apps/api/webview'; await getCurrentWebview().emit('webview-loaded', { loggedIn: true, token: 'authToken' }); ``` **Source**: []() ##### emitTo() ```ts emitTo( target, event, payload?): Promise ``` Emits an event to all [targets](/reference/javascript/api/namespaceevent/#eventtarget) matching the given target. ###### Type Parameters | Type Parameter | | -------------- | | `T` | ###### Parameters | Parameter | Type | Description | | ---------- | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | | `target` | `string` \| [`EventTarget`](/reference/javascript/api/namespaceevent/#eventtarget) | Label of the target Window/Webview/WebviewWindow or raw [EventTarget](/reference/javascript/api/namespaceevent/#eventtarget) object. | | `event` | `string` | Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`. | | `payload`? | `T` | Event payload. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Example ```typescript import { getCurrentWebview } from '@tauri-apps/api/webview'; await getCurrentWebview().emitTo('main', 'webview-loaded', { loggedIn: true, token: 'authToken' }); ``` **Source**: []() ##### hide() ```ts hide(): Promise ``` Hide the webview. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWebview } from '@tauri-apps/api/webview'; await getCurrentWebview().hide(); ``` **Source**: []() ##### listen() ```ts listen(event, handler): Promise ``` Listen to an emitted event on this webview. ###### Type Parameters | Type Parameter | | -------------- | | `T` | ###### Parameters | Parameter | Type | Description | | --------- | -------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | | `event` | [`EventName`](/reference/javascript/api/namespaceevent/#eventname) | Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`. | | `handler` | [`EventCallback`](/reference/javascript/api/namespaceevent/#eventcallbackt)<`T`> | Event handler. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`UnlistenFn`](/reference/javascript/api/namespaceevent/#unlistenfn)> A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted. ###### Example ```typescript import { getCurrentWebview } from '@tauri-apps/api/webview'; const unlisten = await getCurrentWebview().listen('state-changed', (event) => { console.log(`Got error: ${payload}`); }); // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted unlisten(); ``` **Source**: []() ##### onDragDropEvent() ```ts onDragDropEvent(handler): Promise ``` Listen to a file drop event. The listener is triggered when the user hovers the selected files on the webview, drops the files or cancels the operation. ###### Parameters | Parameter | Type | | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | | `handler` | [`EventCallback`](/reference/javascript/api/namespaceevent/#eventcallbackt)<[`DragDropEvent`](/reference/javascript/api/namespacewebview/#dragdropevent)> | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`UnlistenFn`](/reference/javascript/api/namespaceevent/#unlistenfn)> A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted. ###### Example ```typescript import { getCurrentWebview } from "@tauri-apps/api/webview"; const unlisten = await getCurrentWebview().onDragDropEvent((event) => { if (event.payload.type === 'over') { console.log('User hovering', event.payload.position); } else if (event.payload.type === 'drop') { console.log('User dropped', event.payload.paths); } else { console.log('File drop cancelled'); } }); // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted unlisten(); ``` When the debugger panel is open, the drop position of this event may be inaccurate due to a known limitation. To retrieve the correct drop position, please detach the debugger. **Source**: []() ##### once() ```ts once(event, handler): Promise ``` Listen to an emitted event on this webview only once. ###### Type Parameters | Type Parameter | | -------------- | | `T` | ###### Parameters | Parameter | Type | Description | | --------- | -------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | | `event` | [`EventName`](/reference/javascript/api/namespaceevent/#eventname) | Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`. | | `handler` | [`EventCallback`](/reference/javascript/api/namespaceevent/#eventcallbackt)<`T`> | Event handler. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`UnlistenFn`](/reference/javascript/api/namespaceevent/#unlistenfn)> A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted. ###### Example ```typescript import { getCurrentWebview } from '@tauri-apps/api/webview'; const unlisten = await getCurrent().once('initialized', (event) => { console.log(`Webview initialized!`); }); // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted unlisten(); ``` **Source**: []() ##### position() ```ts position(): Promise ``` The position of the top-left hand corner of the webview’s client area relative to the top-left hand corner of the desktop. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`PhysicalPosition`](/reference/javascript/api/namespacedpi/#physicalposition)> The webview’s position. ###### Example ```typescript import { getCurrentWebview } from '@tauri-apps/api/webview'; const position = await getCurrentWebview().position(); ``` **Source**: []() ##### reparent() ```ts reparent(window): Promise ``` Moves this webview to the given label. ###### Parameters | Parameter | Type | | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `window` | `string` \| [`Window`](/reference/javascript/api/namespacewindow/#window) \| [`WebviewWindow`](/reference/javascript/api/namespacewebviewwindow/#webviewwindow) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWebview } from '@tauri-apps/api/webview'; await getCurrentWebview().reparent('other-window'); ``` **Source**: []() ##### setAutoResize() ```ts setAutoResize(autoResize): Promise ``` Sets whether the webview should automatically grow and shrink its size and position when the parent window resizes. ###### Parameters | Parameter | Type | | ------------ | --------- | | `autoResize` | `boolean` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWebview } from '@tauri-apps/api/webview'; await getCurrentWebview().setAutoResize(true); ``` **Source**: []() ##### setBackgroundColor() ```ts setBackgroundColor(color): Promise ``` Specify the webview background color. Platform-specific: * **macOS / iOS**: Not implemented. * **Windows**: * On Windows 7, transparency is not supported and the alpha value will be ignored. * On Windows higher than 7: translucent colors are not supported so any alpha value other than `0` will be replaced by `255` ###### Parameters | Parameter | Type | | --------- | ---------------------------------------------------------------------- | | `color` | `null` \| [`Color`](/reference/javascript/api/namespacewebview/#color) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Since 2.1.0 **Source**: []() ##### setFocus() ```ts setFocus(): Promise ``` Bring the webview to front and focus. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWebview } from '@tauri-apps/api/webview'; await getCurrentWebview().setFocus(); ``` **Source**: []() ##### setPosition() ```ts setPosition(position): Promise ``` Sets the webview position. ###### Parameters | Parameter | Type | Description | | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ | | `position` | [`LogicalPosition`](/reference/javascript/api/namespacedpi/#logicalposition) \| [`PhysicalPosition`](/reference/javascript/api/namespacedpi/#physicalposition) \| [`Position`](/reference/javascript/api/namespacedpi/#position) | The new position, in logical or physical pixels. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrent, LogicalPosition } from '@tauri-apps/api/webview'; await getCurrentWebview().setPosition(new LogicalPosition(600, 500)); ``` **Source**: []() ##### setSize() ```ts setSize(size): Promise ``` Resizes the webview. ###### Parameters | Parameter | Type | Description | | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- | | `size` | [`LogicalSize`](/reference/javascript/api/namespacedpi/#logicalsize) \| [`PhysicalSize`](/reference/javascript/api/namespacedpi/#physicalsize) \| [`Size`](/reference/javascript/api/namespacedpi/#size) | The logical or physical size. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrent, LogicalSize } from '@tauri-apps/api/webview'; await getCurrentWebview().setSize(new LogicalSize(600, 500)); ``` **Source**: []() ##### setZoom() ```ts setZoom(scaleFactor): Promise ``` Set webview zoom level. ###### Parameters | Parameter | Type | | ------------- | -------- | | `scaleFactor` | `number` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWebview } from '@tauri-apps/api/webview'; await getCurrentWebview().setZoom(1.5); ``` **Source**: []() ##### show() ```ts show(): Promise ``` Show the webview. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWebview } from '@tauri-apps/api/webview'; await getCurrentWebview().show(); ``` **Source**: []() ##### size() ```ts size(): Promise ``` The physical size of the webview’s client area. The client area is the content of the webview, excluding the title bar and borders. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`PhysicalSize`](/reference/javascript/api/namespacedpi/#physicalsize)> The webview’s size. ###### Example ```typescript import { getCurrentWebview } from '@tauri-apps/api/webview'; const size = await getCurrentWebview().size(); ``` **Source**: []() ##### getAll() ```ts static getAll(): Promise ``` Gets a list of instances of `Webview` for all available webviews. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Webview`](/reference/javascript/api/namespacewebview/#webview)\[]> **Source**: []() ##### getByLabel() ```ts static getByLabel(label): Promise ``` Gets the Webview for the webview associated with the given label. ###### Parameters | Parameter | Type | Description | | --------- | -------- | ------------------ | | `label` | `string` | The webview label. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`null` | [`Webview`](/reference/javascript/api/namespacewebview/#webview)> The Webview instance to communicate with the webview or null if the webview doesn’t exist. ###### Example ```typescript import { Webview } from '@tauri-apps/api/webview'; const mainWebview = Webview.getByLabel('main'); ``` **Source**: []() ##### getCurrent() ```ts static getCurrent(): Webview ``` Get an instance of `Webview` for the current webview. ###### Returns [`Webview`](/reference/javascript/api/namespacewebview/#webview) **Source**: ## Interfaces []() ### WebviewOptions Configuration for the webview to create. #### Since 2.0.0 #### Properties | Property | Type | Description | Defined in | | -------------------------------- | ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | | []()`acceptFirstMouse?` | `boolean` | Whether clicking an inactive webview also clicks through to the webview on macOS. | **Source**: | | []()`allowLinkPreview?` | `boolean` | on macOS and iOS there is a link preview on long pressing links, this is enabled by default. see | **Source**: | | []()`backgroundColor?` | [`Color`](/reference/javascript/api/namespacewebview/#color) | Set the window and webview background color. Platform-specific: - **macOS / iOS**: Not implemented. - **Windows**: - On Windows 7, alpha channel is ignored. - On Windows 8 and newer, if alpha channel is not `0`, it will be ignored. **Since** 2.1.0 | **Source**: | | []()`backgroundThrottling?` | [`BackgroundThrottlingPolicy`](/reference/javascript/api/namespacewindow/#backgroundthrottlingpolicy) | Change the default background throttling behaviour. By default, browsers use a suspend policy that will throttle timers and even unload the whole tab (view) to free resources after roughly 5 minutes when a view became minimized or hidden. This will pause all tasks until the documents visibility state changes back from hidden to visible by bringing the view back to the foreground. ## Platform-specific - **Linux / Windows / Android**: Unsupported. Workarounds like a pending WebLock transaction might suffice. - **iOS**: Supported since version 17.0+. - **macOS**: Supported since version 14.0+. see **Since** 2.3.0 | **Source**: | | []()`dataDirectory?` | `string` | Set a custom path for the webview’s data directory (localStorage, cache, etc.) **relative to \[`appDataDir()`]/${label}**. For security reasons, paths outside of that location can only be configured on the Rust side. Platform-specific: - **Windows**: WebViews with different values for settings like `additionalBrowserArgs`, `browserExtensionsEnabled` or `scrollBarStyle` must have different data directories. - **macOS / iOS**: Unsupported, use `dataStoreIdentifier` instead. - **Android**: Unsupported. **Since** 2.9.0 | **Source**: | | []()`dataStoreIdentifier?` | `number`\[] | Initialize the WebView with a custom data store identifier. This can be seen as a replacement for `dataDirectory` which is unavailable in WKWebView. See The array must contain 16 u8 numbers. Platform-specific: - **macOS / iOS**: Available on macOS >= 14 and iOS >= 17 - **Windows / Linux / Android**: Unsupported. **Since** 2.9.0 | **Source**: | | []()`devtools?` | `boolean` | Whether web inspector, which is usually called browser devtools, is enabled or not. Enabled by default. This API works in **debug** builds, but requires `devtools` feature flag to enable it in **release** builds. Platform-specific - macOS: This will call private functions on **macOS**. - Android: Open `chrome://inspect/#devices` in Chrome to get the devtools window. Wry’s `WebView` devtools API isn’t supported on Android. - iOS: Open Safari > Develop > \[Your Device Name] > \[Your WebView] to get the devtools window. **Since** 2.1.0 | **Source**: | | []()`disableInputAccessoryView?` | `boolean` | Allows disabling the input accessory view on iOS. The accessory view is the view that appears above the keyboard when a text input element is focused. It usually displays a view with “Done”, “Next” buttons. | **Source**: | | []()`dragDropEnabled?` | `boolean` | Whether the drag and drop is enabled or not on the webview. By default it is enabled. Disabling it is required to use HTML5 drag and drop on the frontend on Windows. | **Source**: | | []()`focus?` | `boolean` | Whether the webview should have focus or not **Since** 2.1.0 | **Source**: | | []()`generalAutofillEnabled?` | `boolean` | Controls the WebView’s browser-level general autofill behavior. **This option does not disable password or credit card autofill.** When set to `false`, the WebView will not automatically populate general form fields using previously stored data such as addresses or contact information. If not specified, this is `true` by default. ## Platform-specific - **Windows**: Supported. WebView2’s autofill feature (called “Suggestions”) may not honor `autocomplete="off"` on input elements in some cases. - **Linux / Android / iOS / macOS**: Unsupported and performs no operation. **Since** 2.11.0 | **Source**: | | []()`height` | `number` | The initial height in logical pixels. | **Source**: | | []()`incognito?` | `boolean` | Whether or not the webview should be launched in incognito mode. Platform-specific - **Android:** Unsupported. | **Source**: | | []()`javascriptDisabled?` | `boolean` | Whether we should disable JavaScript code execution on the webview or not. | **Source**: | | []()`proxyUrl?` | `string` | The proxy URL for the WebView for all network requests. Must be either a `http://` or a `socks5://` URL. Platform-specific - **macOS**: Requires the `macos-proxy` feature flag and only compiles for macOS 14+. | **Source**: | | []()`scrollBarStyle?` | [`ScrollBarStyle`](/reference/javascript/api/namespacewindow/#scrollbarstyle) | Specifies the native scrollbar style to use with the webview. CSS styles that modify the scrollbar are applied on top of the native appearance configured here. Defaults to `default`, which is the browser default. ## Platform-specific - **Windows**: - `fluentOverlay` requires WebView2 Runtime version 125.0.2535.41 or higher, and does nothing on older versions. - This option must be given the same value for all webviews. - **Linux / Android / iOS / macOS**: Unsupported. Only supports `Default` and performs no operation. | **Source**: | | []()`transparent?` | `boolean` | Whether the webview is transparent or not. Note that on `macOS` this requires the `macos-private-api` feature flag, enabled under `tauri.conf.json > app > macOSPrivateApi`. WARNING: Using private APIs on `macOS` prevents your application from being accepted to the `App Store`. | **Source**: | | []()`url?` | `string` | Remote URL or local file path to open. - URL such as `https://github.com/tauri-apps` is opened directly on a Tauri webview. - data: URL such as `data:text/html,...` is only supported with the `webview-data-url` Cargo feature for the `tauri` dependency. - local file path or route such as `/path/to/page.html` or `/users` is appended to the application URL (the devServer URL on development, or `tauri://localhost/` and `https://tauri.localhost/` on production). | **Source**: | | []()`useHttpsScheme?` | `boolean` | Sets whether the custom protocols should use `https://.localhost` instead of the default `http://.localhost` on Windows and Android. Defaults to `false`. #### Note Using a `https` scheme will NOT allow mixed content when trying to fetch `http` endpoints and therefore will not match the behavior of the `://localhost` protocols used on macOS and Linux. #### Warning Changing this value between releases will change the IndexedDB, cookies and localstorage location and your app will not be able to access them. **Since** 2.1.0 | **Source**: | | []()`userAgent?` | `string` | The user agent for the webview. | **Source**: | | []()`width` | `number` | The initial width in logical pixels. | **Source**: | | []()`x` | `number` | The initial vertical position in logical pixels. | **Source**: | | []()`y` | `number` | The initial horizontal position in logical pixels. | **Source**: | | []()`zoomHotkeysEnabled?` | `boolean` | Whether page zooming by hotkeys is enabled Platform-specific: - **Windows**: Controls WebView2’s [`IsZoomControlEnabled`](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2settings?view=webview2-winrt-1.0.2420.47#iszoomcontrolenabled) setting. - **MacOS / Linux**: Injects a polyfill that zooms in and out with `ctrl/command` + `-/=`, 20% in each step, ranging from 20% to 1000%. Requires `webview:allow-set-webview-zoom` permission - **Android / iOS**: Unsupported. | **Source**: | ## Type Aliases []() ### Color ```ts type Color: [number, number, number] | [number, number, number, number] | object | string; ``` An RGBA color. Each value has minimum of 0 and maximum of 255. It can be either a string `#ffffff`, an array of 3 or 4 elements or an object. #### Since 2.0.0 **Source**: *** []() ### DragDropEvent ```ts type DragDropEvent: object | object | object | object; ``` The drag and drop event types. **Source**: ## Functions []() ### getAllWebviews() ```ts function getAllWebviews(): Promise ``` Gets a list of instances of `Webview` for all available webviews. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Webview`](/reference/javascript/api/namespacewebview/#webview)\[]> #### Since 2.0.0 **Source**: *** []() ### getCurrentWebview() ```ts function getCurrentWebview(): Webview ``` Get an instance of `Webview` for the current webview. #### Returns [`Webview`](/reference/javascript/api/namespacewebview/#webview) #### Since 2.0.0 **Source**: # webviewWindow ## References []() ### Color Re-exports [Color](/reference/javascript/api/namespacewebview/#color) []() ### DragDropEvent Re-exports [DragDropEvent](/reference/javascript/api/namespacewebview/#dragdropevent) ## Classes []() ### WebviewWindow Create new webview or get a handle to an existing one. Webviews are identified by a *label* a unique identifier that can be used to reference it later. It may only contain alphanumeric characters `a-zA-Z` plus the following special characters `-`, `/`, `:` and `_`. #### Example ```typescript import { Window } from "@tauri-apps/api/window" import { Webview } from "@tauri-apps/api/webview" const appWindow = new Window('uniqueLabel'); appWindow.once('tauri://created', async function () { // `new Webview` Should be called after the window is successfully created, // or webview may not be attached to the window since window is not created yet. // loading embedded asset: const webview = new Webview(appWindow, 'theUniqueLabel', { url: 'path/to/page.html', // create a webview with specific logical position and size x: 0, y: 0, width: 800, height: 600, }); // alternatively, load a remote URL: const webview = new Webview(appWindow, 'theUniqueLabel', { url: 'https://github.com/tauri-apps/tauri', // create a webview with specific logical position and size x: 0, y: 0, width: 800, height: 600, }); webview.once('tauri://created', function () { // webview successfully created }); webview.once('tauri://error', function (e) { // an error happened creating the webview }); // emit an event to the backend await webview.emit("some-event", "data"); // listen to an event from the backend const unlisten = await webview.listen("event-name", e => { }); unlisten(); }); ``` #### Since 2.0.0 #### Extends * [`Webview`](/reference/javascript/api/namespacewebview/#webview).[`Window`](/reference/javascript/api/namespacewindow/#window) #### Constructors []() ##### new WebviewWindow() ```ts new WebviewWindow(label, options): WebviewWindow ``` Creates a new [Window](/reference/javascript/api/namespacewindow/#window) hosting a [Webview](/reference/javascript/api/namespacewebview/#webview). ###### Parameters | Parameter | Type | Description | | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------- | | `label` | `string` | The unique webview label. Must be alphanumeric: `a-zA-Z-/:_`. | | `options` | [`Omit`](https://www.typescriptlang.org/docs/handbook/utility-types.html#omittype-keys)<[`WebviewOptions`](/reference/javascript/api/namespacewebview/#webviewoptions), `"x"` \| `"y"` \| `"width"` \| `"height"`> & [`WindowOptions`](/reference/javascript/api/namespacewindow/#windowoptions) | - | ###### Returns [`WebviewWindow`](/reference/javascript/api/namespacewebviewwindow/#webviewwindow) The [WebviewWindow](/reference/javascript/api/namespacewebviewwindow/#webviewwindow) instance to communicate with the window and webview. ###### Example ```typescript import { WebviewWindow } from '@tauri-apps/api/webviewWindow' const webview = new WebviewWindow('my-label', { url: 'https://github.com/tauri-apps/tauri' }); webview.once('tauri://created', function () { // webview successfully created }); webview.once('tauri://error', function (e) { // an error happened creating the webview }); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`constructor`](/reference/javascript/api/namespacewindow/#constructors-1) **Source**: #### Properties | Property | Type | Description | Inherited from | Defined in | | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ | | []()`label` | `string` | The webview label. It is a unique identifier for the webview, can be used to reference it later. | [`Window`](/reference/javascript/api/namespacewindow/#window).[`label`](/reference/javascript/api/namespacewindow/#label) | **Source**: | | []()`listeners` | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)<`string`, [`EventCallback`](/reference/javascript/api/namespaceevent/#eventcallbackt)<`any`>\[]> | Local event listeners. | [`Window`](/reference/javascript/api/namespacewindow/#window).[`listeners`](/reference/javascript/api/namespacewindow/#listeners) | **Source**: | | []()`window` | [`Window`](/reference/javascript/api/namespacewindow/#window) | The window hosting this webview. | [`Webview`](/reference/javascript/api/namespacewebview/#webview).[`window`](/reference/javascript/api/namespacewebview/#window) | **Source**: | #### Methods []() ##### activityName() ```ts activityName(): Promise ``` ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`activityName`](/reference/javascript/api/namespacewindow/#activityname) **Source**: []() ##### center() ```ts center(): Promise ``` Centers the window. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().center(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`center`](/reference/javascript/api/namespacewindow/#center) **Source**: []() ##### clearAllBrowsingData() ```ts clearAllBrowsingData(): Promise ``` Clears all browsing data for this webview. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWebview } from '@tauri-apps/api/webview'; await getCurrentWebview().clearAllBrowsingData(); ``` ###### Inherited from [`Webview`](/reference/javascript/api/namespacewebview/#webview).[`clearAllBrowsingData`](/reference/javascript/api/namespacewebview/#clearallbrowsingdata) **Source**: []() ##### clearEffects() ```ts clearEffects(): Promise ``` Clear any applied effects if possible. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`clearEffects`](/reference/javascript/api/namespacewindow/#cleareffects) **Source**: []() ##### close() ```ts close(): Promise ``` Closes the webview. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWebview } from '@tauri-apps/api/webview'; await getCurrentWebview().close(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`close`](/reference/javascript/api/namespacewindow/#close) **Source**: []() ##### destroy() ```ts destroy(): Promise ``` Destroys the window. Behaves like [Window.close](/reference/javascript/api/namespacewindow/#close) but forces the window close instead of emitting a closeRequested event. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().destroy(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`destroy`](/reference/javascript/api/namespacewindow/#destroy) **Source**: []() ##### emit() ```ts emit(event, payload?): Promise ``` Emits an event to all [targets](/reference/javascript/api/namespaceevent/#eventtarget). ###### Type Parameters | Type Parameter | | -------------- | | `T` | ###### Parameters | Parameter | Type | Description | | ---------- | -------- | ----------------------------------------------------------------------------- | | `event` | `string` | Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`. | | `payload`? | `T` | Event payload. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Example ```typescript import { getCurrentWebview } from '@tauri-apps/api/webview'; await getCurrentWebview().emit('webview-loaded', { loggedIn: true, token: 'authToken' }); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`emit`](/reference/javascript/api/namespacewindow/#emit) **Source**: []() ##### emitTo() ```ts emitTo( target, event, payload?): Promise ``` Emits an event to all [targets](/reference/javascript/api/namespaceevent/#eventtarget) matching the given target. ###### Type Parameters | Type Parameter | | -------------- | | `T` | ###### Parameters | Parameter | Type | Description | | ---------- | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | | `target` | `string` \| [`EventTarget`](/reference/javascript/api/namespaceevent/#eventtarget) | Label of the target Window/Webview/WebviewWindow or raw [EventTarget](/reference/javascript/api/namespaceevent/#eventtarget) object. | | `event` | `string` | Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`. | | `payload`? | `T` | Event payload. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Example ```typescript import { getCurrentWebview } from '@tauri-apps/api/webview'; await getCurrentWebview().emitTo('main', 'webview-loaded', { loggedIn: true, token: 'authToken' }); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`emitTo`](/reference/javascript/api/namespacewindow/#emitto) **Source**: []() ##### hide() ```ts hide(): Promise ``` Hide the webview. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWebview } from '@tauri-apps/api/webview'; await getCurrentWebview().hide(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`hide`](/reference/javascript/api/namespacewindow/#hide) **Source**: []() ##### innerPosition() ```ts innerPosition(): Promise ``` The position of the top-left hand corner of the window’s client area relative to the top-left hand corner of the desktop. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`PhysicalPosition`](/reference/javascript/api/namespacedpi/#physicalposition)> The window’s inner position. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const position = await getCurrentWindow().innerPosition(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`innerPosition`](/reference/javascript/api/namespacewindow/#innerposition) **Source**: []() ##### innerSize() ```ts innerSize(): Promise ``` The physical size of the window’s client area. The client area is the content of the window, excluding the title bar and borders. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`PhysicalSize`](/reference/javascript/api/namespacedpi/#physicalsize)> The window’s inner size. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const size = await getCurrentWindow().innerSize(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`innerSize`](/reference/javascript/api/namespacewindow/#innersize) **Source**: []() ##### isAlwaysOnTop() ```ts isAlwaysOnTop(): Promise ``` Whether the window is configured to be always on top of other windows or not. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> Whether the window is visible or not. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const alwaysOnTop = await getCurrentWindow().isAlwaysOnTop(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`isAlwaysOnTop`](/reference/javascript/api/namespacewindow/#isalwaysontop) **Source**: []() ##### isClosable() ```ts isClosable(): Promise ``` Gets the window’s native close button state. Platform-specific * **iOS / Android:** Unsupported. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> Whether the window’s native close button is enabled or not. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const closable = await getCurrentWindow().isClosable(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`isClosable`](/reference/javascript/api/namespacewindow/#isclosable) **Source**: []() ##### isDecorated() ```ts isDecorated(): Promise ``` Gets the window’s current decorated state. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> Whether the window is decorated or not. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const decorated = await getCurrentWindow().isDecorated(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`isDecorated`](/reference/javascript/api/namespacewindow/#isdecorated) **Source**: []() ##### isEnabled() ```ts isEnabled(): Promise ``` Whether the window is enabled or disabled. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setEnabled(false); ``` ###### Since 2.0.0 ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`isEnabled`](/reference/javascript/api/namespacewindow/#isenabled) **Source**: []() ##### isFocused() ```ts isFocused(): Promise ``` Gets the window’s current focus state. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> Whether the window is focused or not. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const focused = await getCurrentWindow().isFocused(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`isFocused`](/reference/javascript/api/namespacewindow/#isfocused) **Source**: []() ##### isFullscreen() ```ts isFullscreen(): Promise ``` Gets the window’s current fullscreen state. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> Whether the window is in fullscreen mode or not. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const fullscreen = await getCurrentWindow().isFullscreen(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`isFullscreen`](/reference/javascript/api/namespacewindow/#isfullscreen) **Source**: []() ##### isMaximizable() ```ts isMaximizable(): Promise ``` Gets the window’s native maximize button state. Platform-specific * **Linux / iOS / Android:** Unsupported. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> Whether the window’s native maximize button is enabled or not. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const maximizable = await getCurrentWindow().isMaximizable(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`isMaximizable`](/reference/javascript/api/namespacewindow/#ismaximizable) **Source**: []() ##### isMaximized() ```ts isMaximized(): Promise ``` Gets the window’s current maximized state. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> Whether the window is maximized or not. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const maximized = await getCurrentWindow().isMaximized(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`isMaximized`](/reference/javascript/api/namespacewindow/#ismaximized) **Source**: []() ##### isMinimizable() ```ts isMinimizable(): Promise ``` Gets the window’s native minimize button state. Platform-specific * **Linux / iOS / Android:** Unsupported. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> Whether the window’s native minimize button is enabled or not. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const minimizable = await getCurrentWindow().isMinimizable(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`isMinimizable`](/reference/javascript/api/namespacewindow/#isminimizable) **Source**: []() ##### isMinimized() ```ts isMinimized(): Promise ``` Gets the window’s current minimized state. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const minimized = await getCurrentWindow().isMinimized(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`isMinimized`](/reference/javascript/api/namespacewindow/#isminimized) **Source**: []() ##### isResizable() ```ts isResizable(): Promise ``` Gets the window’s current resizable state. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> Whether the window is resizable or not. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const resizable = await getCurrentWindow().isResizable(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`isResizable`](/reference/javascript/api/namespacewindow/#isresizable) **Source**: []() ##### isVisible() ```ts isVisible(): Promise ``` Gets the window’s current visible state. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> Whether the window is visible or not. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const visible = await getCurrentWindow().isVisible(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`isVisible`](/reference/javascript/api/namespacewindow/#isvisible) **Source**: []() ##### listen() ```ts listen(event, handler): Promise ``` Listen to an emitted event on this webview window. ###### Type Parameters | Type Parameter | | -------------- | | `T` | ###### Parameters | Parameter | Type | Description | | --------- | -------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | | `event` | [`EventName`](/reference/javascript/api/namespaceevent/#eventname) | Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`. | | `handler` | [`EventCallback`](/reference/javascript/api/namespaceevent/#eventcallbackt)<`T`> | Event handler. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`UnlistenFn`](/reference/javascript/api/namespaceevent/#unlistenfn)> A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted. ###### Example ```typescript import { WebviewWindow } from '@tauri-apps/api/webviewWindow'; const unlisten = await WebviewWindow.getCurrent().listen('state-changed', (event) => { console.log(`Got error: ${payload}`); }); // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted unlisten(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`listen`](/reference/javascript/api/namespacewindow/#listen) **Source**: []() ##### maximize() ```ts maximize(): Promise ``` Maximizes the window. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().maximize(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`maximize`](/reference/javascript/api/namespacewindow/#maximize) **Source**: []() ##### minimize() ```ts minimize(): Promise ``` Minimizes the window. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().minimize(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`minimize`](/reference/javascript/api/namespacewindow/#minimize) **Source**: []() ##### onCloseRequested() ```ts onCloseRequested(handler): Promise ``` Listen to window close requested. Emitted when the user requests to closes the window. ###### Parameters | Parameter | Type | | --------- | ------------------------------------------------------------------------------------------------------------------------------ | | `handler` | (`event`) => `void` \| [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`UnlistenFn`](/reference/javascript/api/namespaceevent/#unlistenfn)> A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted. ###### Example ```typescript import { getCurrentWindow } from "@tauri-apps/api/window"; import { confirm } from '@tauri-apps/api/dialog'; const unlisten = await getCurrentWindow().onCloseRequested(async (event) => { const confirmed = await confirm('Are you sure?'); if (!confirmed) { // user did not confirm closing the window; let's prevent it event.preventDefault(); } }); // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted unlisten(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`onCloseRequested`](/reference/javascript/api/namespacewindow/#oncloserequested) **Source**: []() ##### onDragDropEvent() ```ts onDragDropEvent(handler): Promise ``` Listen to a file drop event. The listener is triggered when the user hovers the selected files on the webview, drops the files or cancels the operation. ###### Parameters | Parameter | Type | | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | | `handler` | [`EventCallback`](/reference/javascript/api/namespaceevent/#eventcallbackt)<[`DragDropEvent`](/reference/javascript/api/namespacewebview/#dragdropevent)> | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`UnlistenFn`](/reference/javascript/api/namespaceevent/#unlistenfn)> A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted. ###### Example ```typescript import { getCurrentWebview } from "@tauri-apps/api/webview"; const unlisten = await getCurrentWebview().onDragDropEvent((event) => { if (event.payload.type === 'over') { console.log('User hovering', event.payload.position); } else if (event.payload.type === 'drop') { console.log('User dropped', event.payload.paths); } else { console.log('File drop cancelled'); } }); // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted unlisten(); ``` When the debugger panel is open, the drop position of this event may be inaccurate due to a known limitation. To retrieve the correct drop position, please detach the debugger. ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`onDragDropEvent`](/reference/javascript/api/namespacewindow/#ondragdropevent) **Source**: []() ##### onFocusChanged() ```ts onFocusChanged(handler): Promise ``` Listen to window focus change. ###### Parameters | Parameter | Type | | --------- | -------------------------------------------------------------------------------------- | | `handler` | [`EventCallback`](/reference/javascript/api/namespaceevent/#eventcallbackt)<`boolean`> | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`UnlistenFn`](/reference/javascript/api/namespaceevent/#unlistenfn)> A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted. ###### Example ```typescript import { getCurrentWindow } from "@tauri-apps/api/window"; const unlisten = await getCurrentWindow().onFocusChanged(({ payload: focused }) => { console.log('Focus changed, window is focused? ' + focused); }); // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted unlisten(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`onFocusChanged`](/reference/javascript/api/namespacewindow/#onfocuschanged) **Source**: []() ##### onMoved() ```ts onMoved(handler): Promise ``` Listen to window move. ###### Parameters | Parameter | Type | | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | | `handler` | [`EventCallback`](/reference/javascript/api/namespaceevent/#eventcallbackt)<[`PhysicalPosition`](/reference/javascript/api/namespacedpi/#physicalposition)> | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`UnlistenFn`](/reference/javascript/api/namespaceevent/#unlistenfn)> A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted. ###### Example ```typescript import { getCurrentWindow } from "@tauri-apps/api/window"; const unlisten = await getCurrentWindow().onMoved(({ payload: position }) => { console.log('Window moved', position); }); // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted unlisten(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`onMoved`](/reference/javascript/api/namespacewindow/#onmoved) **Source**: []() ##### onResized() ```ts onResized(handler): Promise ``` Listen to window resize. ###### Parameters | Parameter | Type | | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | | `handler` | [`EventCallback`](/reference/javascript/api/namespaceevent/#eventcallbackt)<[`PhysicalSize`](/reference/javascript/api/namespacedpi/#physicalsize)> | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`UnlistenFn`](/reference/javascript/api/namespaceevent/#unlistenfn)> A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted. ###### Example ```typescript import { getCurrentWindow } from "@tauri-apps/api/window"; const unlisten = await getCurrentWindow().onResized(({ payload: size }) => { console.log('Window resized', size); }); // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted unlisten(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`onResized`](/reference/javascript/api/namespacewindow/#onresized) **Source**: []() ##### onScaleChanged() ```ts onScaleChanged(handler): Promise ``` Listen to window scale change. Emitted when the window’s scale factor has changed. The following user actions can cause DPI changes: * Changing the display’s resolution. * Changing the display’s scale factor (e.g. in Control Panel on Windows). * Moving the window to a display with a different scale factor. ###### Parameters | Parameter | Type | | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `handler` | [`EventCallback`](/reference/javascript/api/namespaceevent/#eventcallbackt)<[`ScaleFactorChanged`](/reference/javascript/api/namespacewindow/#scalefactorchanged)> | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`UnlistenFn`](/reference/javascript/api/namespaceevent/#unlistenfn)> A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted. ###### Example ```typescript import { getCurrentWindow } from "@tauri-apps/api/window"; const unlisten = await getCurrentWindow().onScaleChanged(({ payload }) => { console.log('Scale changed', payload.scaleFactor, payload.size); }); // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted unlisten(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`onScaleChanged`](/reference/javascript/api/namespacewindow/#onscalechanged) **Source**: []() ##### onThemeChanged() ```ts onThemeChanged(handler): Promise ``` Listen to the system theme change. ###### Parameters | Parameter | Type | | --------- | ------------------------------------------------------------------------------------------------------------------------------------------ | | `handler` | [`EventCallback`](/reference/javascript/api/namespaceevent/#eventcallbackt)<[`Theme`](/reference/javascript/api/namespacewindow/#theme-2)> | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`UnlistenFn`](/reference/javascript/api/namespaceevent/#unlistenfn)> A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted. ###### Example ```typescript import { getCurrentWindow } from "@tauri-apps/api/window"; const unlisten = await getCurrentWindow().onThemeChanged(({ payload: theme }) => { console.log('New theme: ' + theme); }); // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted unlisten(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`onThemeChanged`](/reference/javascript/api/namespacewindow/#onthemechanged) **Source**: []() ##### once() ```ts once(event, handler): Promise ``` Listen to an emitted event on this webview window only once. ###### Type Parameters | Type Parameter | | -------------- | | `T` | ###### Parameters | Parameter | Type | Description | | --------- | -------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | | `event` | [`EventName`](/reference/javascript/api/namespaceevent/#eventname) | Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`. | | `handler` | [`EventCallback`](/reference/javascript/api/namespaceevent/#eventcallbackt)<`T`> | Event handler. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`UnlistenFn`](/reference/javascript/api/namespaceevent/#unlistenfn)> A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted. ###### Example ```typescript import { WebviewWindow } from '@tauri-apps/api/webviewWindow'; const unlisten = await WebviewWindow.getCurrent().once('initialized', (event) => { console.log(`Webview initialized!`); }); // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted unlisten(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`once`](/reference/javascript/api/namespacewindow/#once) **Source**: []() ##### outerPosition() ```ts outerPosition(): Promise ``` The position of the top-left hand corner of the window relative to the top-left hand corner of the desktop. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`PhysicalPosition`](/reference/javascript/api/namespacedpi/#physicalposition)> The window’s outer position. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const position = await getCurrentWindow().outerPosition(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`outerPosition`](/reference/javascript/api/namespacewindow/#outerposition) **Source**: []() ##### outerSize() ```ts outerSize(): Promise ``` The physical size of the entire window. These dimensions include the title bar and borders. If you don’t want that (and you usually don’t), use inner\_size instead. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`PhysicalSize`](/reference/javascript/api/namespacedpi/#physicalsize)> The window’s outer size. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const size = await getCurrentWindow().outerSize(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`outerSize`](/reference/javascript/api/namespacewindow/#outersize) **Source**: []() ##### position() ```ts position(): Promise ``` The position of the top-left hand corner of the webview’s client area relative to the top-left hand corner of the desktop. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`PhysicalPosition`](/reference/javascript/api/namespacedpi/#physicalposition)> The webview’s position. ###### Example ```typescript import { getCurrentWebview } from '@tauri-apps/api/webview'; const position = await getCurrentWebview().position(); ``` ###### Inherited from [`Webview`](/reference/javascript/api/namespacewebview/#webview).[`position`](/reference/javascript/api/namespacewebview/#position) **Source**: []() ##### reparent() ```ts reparent(window): Promise ``` Moves this webview to the given label. ###### Parameters | Parameter | Type | | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `window` | `string` \| [`Window`](/reference/javascript/api/namespacewindow/#window) \| [`WebviewWindow`](/reference/javascript/api/namespacewebviewwindow/#webviewwindow) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWebview } from '@tauri-apps/api/webview'; await getCurrentWebview().reparent('other-window'); ``` ###### Inherited from [`Webview`](/reference/javascript/api/namespacewebview/#webview).[`reparent`](/reference/javascript/api/namespacewebview/#reparent) **Source**: []() ##### requestUserAttention() ```ts requestUserAttention(requestType): Promise ``` Requests user attention to the window, this has no effect if the application is already focused. How requesting for user attention manifests is platform dependent, see `UserAttentionType` for details. Providing `null` will unset the request for user attention. Unsetting the request for user attention might not be done automatically by the WM when the window receives input. Platform-specific * **macOS:** `null` has no effect. * **Linux:** Urgency levels have the same effect. ###### Parameters | Parameter | Type | | ------------- | --------------------------------------------------------------------------------------------- | | `requestType` | `null` \| [`UserAttentionType`](/reference/javascript/api/namespacewindow/#userattentiontype) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().requestUserAttention(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`requestUserAttention`](/reference/javascript/api/namespacewindow/#requestuserattention) **Source**: []() ##### scaleFactor() ```ts scaleFactor(): Promise ``` The scale factor that can be used to map physical pixels to logical pixels. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`number`> The window’s monitor scale factor. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const factor = await getCurrentWindow().scaleFactor(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`scaleFactor`](/reference/javascript/api/namespacewindow/#scalefactor) **Source**: []() ##### sceneIdentifier() ```ts sceneIdentifier(): Promise ``` ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`sceneIdentifier`](/reference/javascript/api/namespacewindow/#sceneidentifier) **Source**: []() ##### setAlwaysOnBottom() ```ts setAlwaysOnBottom(alwaysOnBottom): Promise ``` Whether the window should always be below other windows. ###### Parameters | Parameter | Type | Description | | ---------------- | --------- | --------------------------------------------------------------- | | `alwaysOnBottom` | `boolean` | Whether the window should always be below other windows or not. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setAlwaysOnBottom(true); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setAlwaysOnBottom`](/reference/javascript/api/namespacewindow/#setalwaysonbottom) **Source**: []() ##### setAlwaysOnTop() ```ts setAlwaysOnTop(alwaysOnTop): Promise ``` Whether the window should always be on top of other windows. ###### Parameters | Parameter | Type | Description | | ------------- | --------- | ------------------------------------------------------------------- | | `alwaysOnTop` | `boolean` | Whether the window should always be on top of other windows or not. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setAlwaysOnTop(true); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setAlwaysOnTop`](/reference/javascript/api/namespacewindow/#setalwaysontop) **Source**: []() ##### setAutoResize() ```ts setAutoResize(autoResize): Promise ``` Sets whether the webview should automatically grow and shrink its size and position when the parent window resizes. ###### Parameters | Parameter | Type | | ------------ | --------- | | `autoResize` | `boolean` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWebview } from '@tauri-apps/api/webview'; await getCurrentWebview().setAutoResize(true); ``` ###### Inherited from [`Webview`](/reference/javascript/api/namespacewebview/#webview).[`setAutoResize`](/reference/javascript/api/namespacewebview/#setautoresize) **Source**: []() ##### setBackgroundColor() ```ts setBackgroundColor(color): Promise ``` Set the window and webview background color. Platform-specific: * **Android / iOS:** Unsupported for the window layer. * **macOS / iOS**: Not implemented for the webview layer. * **Windows**: * alpha channel is ignored for the window layer. * On Windows 7, alpha channel is ignored for the webview layer. * On Windows 8 and newer, if alpha channel is not `0`, it will be ignored. ###### Parameters | Parameter | Type | | --------- | ------------------------------------------------------------ | | `color` | [`Color`](/reference/javascript/api/namespacewebview/#color) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Since 2.1.0 ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setBackgroundColor`](/reference/javascript/api/namespacewindow/#setbackgroundcolor) **Source**: []() ##### setBadgeCount() ```ts setBadgeCount(count?): Promise ``` Sets the badge count. It is app wide and not specific to this window. Platform-specific * **Windows**: Unsupported. Use @{linkcode Window\.setOverlayIcon} instead. ###### Parameters | Parameter | Type | Description | | --------- | -------- | ----------------------------------------------------- | | `count`? | `number` | The badge count. Use `undefined` to remove the badge. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setBadgeCount(5); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setBadgeCount`](/reference/javascript/api/namespacewindow/#setbadgecount) **Source**: []() ##### setBadgeLabel() ```ts setBadgeLabel(label?): Promise ``` Sets the badge cont **macOS only**. ###### Parameters | Parameter | Type | Description | | --------- | -------- | ----------------------------------------------------- | | `label`? | `string` | The badge label. Use `undefined` to remove the badge. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setBadgeLabel("Hello"); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setBadgeLabel`](/reference/javascript/api/namespacewindow/#setbadgelabel) **Source**: []() ##### setClosable() ```ts setClosable(closable): Promise ``` Sets whether the window’s native close button is enabled or not. Platform-specific * **Linux:** GTK+ will do its best to convince the window manager not to show a close button. Depending on the system, this function may not have any effect when called on a window that is already visible * **iOS / Android:** Unsupported. ###### Parameters | Parameter | Type | | ---------- | --------- | | `closable` | `boolean` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setClosable(false); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setClosable`](/reference/javascript/api/namespacewindow/#setclosable) **Source**: []() ##### setContentProtected() ```ts setContentProtected(protected_): Promise ``` Prevents the window contents from being captured by other apps. ###### Parameters | Parameter | Type | | ------------ | --------- | | `protected_` | `boolean` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setContentProtected(true); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setContentProtected`](/reference/javascript/api/namespacewindow/#setcontentprotected) **Source**: []() ##### setCursorGrab() ```ts setCursorGrab(grab): Promise ``` Grabs the cursor, preventing it from leaving the window. There’s no guarantee that the cursor will be hidden. You should hide it by yourself if you want so. Platform-specific * **Linux:** Unsupported. * **macOS:** This locks the cursor in a fixed location, which looks visually awkward. ###### Parameters | Parameter | Type | Description | | --------- | --------- | ------------------------------------------------------ | | `grab` | `boolean` | `true` to grab the cursor icon, `false` to release it. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setCursorGrab(true); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setCursorGrab`](/reference/javascript/api/namespacewindow/#setcursorgrab) **Source**: []() ##### setCursorIcon() ```ts setCursorIcon(icon): Promise ``` Modifies the cursor icon of the window. ###### Parameters | Parameter | Type | Description | | --------- | --------------------------------------------------------------------- | -------------------- | | `icon` | [`CursorIcon`](/reference/javascript/api/namespacewindow/#cursoricon) | The new cursor icon. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setCursorIcon('help'); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setCursorIcon`](/reference/javascript/api/namespacewindow/#setcursoricon) **Source**: []() ##### setCursorPosition() ```ts setCursorPosition(position): Promise ``` Changes the position of the cursor in window coordinates. ###### Parameters | Parameter | Type | Description | | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------ | | `position` | [`LogicalPosition`](/reference/javascript/api/namespacedpi/#logicalposition) \| [`PhysicalPosition`](/reference/javascript/api/namespacedpi/#physicalposition) \| [`Position`](/reference/javascript/api/namespacedpi/#position) | The new cursor position. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow, LogicalPosition } from '@tauri-apps/api/window'; await getCurrentWindow().setCursorPosition(new LogicalPosition(600, 300)); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setCursorPosition`](/reference/javascript/api/namespacewindow/#setcursorposition) **Source**: []() ##### setCursorVisible() ```ts setCursorVisible(visible): Promise ``` Modifies the cursor’s visibility. Platform-specific * **Windows:** The cursor is only hidden within the confines of the window. * **macOS:** The cursor is hidden as long as the window has input focus, even if the cursor is outside of the window. ###### Parameters | Parameter | Type | Description | | --------- | --------- | ---------------------------------------------------------------------------- | | `visible` | `boolean` | If `false`, this will hide the cursor. If `true`, this will show the cursor. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setCursorVisible(false); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setCursorVisible`](/reference/javascript/api/namespacewindow/#setcursorvisible) **Source**: []() ##### setDecorations() ```ts setDecorations(decorations): Promise ``` Whether the window should have borders and bars. ###### Parameters | Parameter | Type | Description | | ------------- | --------- | ------------------------------------------------ | | `decorations` | `boolean` | Whether the window should have borders and bars. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setDecorations(false); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setDecorations`](/reference/javascript/api/namespacewindow/#setdecorations) **Source**: []() ##### setEffects() ```ts setEffects(effects): Promise ``` Set window effects. ###### Parameters | Parameter | Type | | --------- | --------------------------------------------------------------- | | `effects` | [`Effects`](/reference/javascript/api/namespacewindow/#effects) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setEffects`](/reference/javascript/api/namespacewindow/#seteffects) **Source**: []() ##### setEnabled() ```ts setEnabled(enabled): Promise ``` Enable or disable the window. ###### Parameters | Parameter | Type | | --------- | --------- | | `enabled` | `boolean` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setEnabled(false); ``` ###### Since 2.0.0 ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setEnabled`](/reference/javascript/api/namespacewindow/#setenabled) **Source**: []() ##### setFocus() ```ts setFocus(): Promise ``` Bring the webview to front and focus. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWebview } from '@tauri-apps/api/webview'; await getCurrentWebview().setFocus(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setFocus`](/reference/javascript/api/namespacewindow/#setfocus) **Source**: []() ##### setFocusable() ```ts setFocusable(focusable): Promise ``` Sets whether the window can be focused. Platform-specific * **macOS**: If the window is already focused, it is not possible to unfocus it after calling `set_focusable(false)`. In this case, you might consider calling [Window.setFocus](/reference/javascript/api/namespacewindow/#setfocus) but it will move the window to the back i.e. at the bottom in terms of z-order. ###### Parameters | Parameter | Type | Description | | ----------- | --------- | ---------------------------------- | | `focusable` | `boolean` | Whether the window can be focused. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setFocusable(true); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setFocusable`](/reference/javascript/api/namespacewindow/#setfocusable) **Source**: []() ##### setFullscreen() ```ts setFullscreen(fullscreen): Promise ``` Sets the window fullscreen state. ###### Parameters | Parameter | Type | Description | | ------------ | --------- | -------------------------------------------------- | | `fullscreen` | `boolean` | Whether the window should go to fullscreen or not. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setFullscreen(true); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setFullscreen`](/reference/javascript/api/namespacewindow/#setfullscreen) **Source**: []() ##### setIcon() ```ts setIcon(icon): Promise ``` Sets the window icon. ###### Parameters | Parameter | Type | Description | | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------ | | `icon` | \| `string` \| [`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) \| `number`\[] \| [`ArrayBuffer`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) \| [`Image`](/reference/javascript/api/namespaceimage/#image) | Icon bytes or path to the icon file. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setIcon('/tauri/awesome.png'); ``` Note that you may need the `image-ico` or `image-png` Cargo features to use this API. To enable it, change your Cargo.toml file: ```toml [dependencies] tauri = { version = "...", features = ["...", "image-png"] } ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setIcon`](/reference/javascript/api/namespacewindow/#seticon) **Source**: []() ##### setIgnoreCursorEvents() ```ts setIgnoreCursorEvents(ignore): Promise ``` Changes the cursor events behavior. ###### Parameters | Parameter | Type | Description | | --------- | --------- | --------------------------------------------------------------------- | | `ignore` | `boolean` | `true` to ignore the cursor events; `false` to process them as usual. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setIgnoreCursorEvents(true); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setIgnoreCursorEvents`](/reference/javascript/api/namespacewindow/#setignorecursorevents) **Source**: []() ##### setMaxSize() ```ts setMaxSize(size): Promise ``` Sets the window maximum inner size. If the `size` argument is undefined, the constraint is unset. ###### Parameters | Parameter | Type | Description | | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------- | | `size` | \| `undefined` \| `null` \| [`LogicalSize`](/reference/javascript/api/namespacedpi/#logicalsize) \| [`PhysicalSize`](/reference/javascript/api/namespacedpi/#physicalsize) \| [`Size`](/reference/javascript/api/namespacedpi/#size) | The logical or physical inner size, or `null` to unset the constraint. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow, LogicalSize } from '@tauri-apps/api/window'; await getCurrentWindow().setMaxSize(new LogicalSize(600, 500)); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setMaxSize`](/reference/javascript/api/namespacewindow/#setmaxsize) **Source**: []() ##### setMaximizable() ```ts setMaximizable(maximizable): Promise ``` Sets whether the window’s native maximize button is enabled or not. If resizable is set to false, this setting is ignored. Platform-specific * **macOS:** Disables the “zoom” button in the window titlebar, which is also used to enter fullscreen mode. * **Linux / iOS / Android:** Unsupported. ###### Parameters | Parameter | Type | | ------------- | --------- | | `maximizable` | `boolean` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setMaximizable(false); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setMaximizable`](/reference/javascript/api/namespacewindow/#setmaximizable) **Source**: []() ##### setMinSize() ```ts setMinSize(size): Promise ``` Sets the window minimum inner size. If the `size` argument is not provided, the constraint is unset. ###### Parameters | Parameter | Type | Description | | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------- | | `size` | \| `undefined` \| `null` \| [`LogicalSize`](/reference/javascript/api/namespacedpi/#logicalsize) \| [`PhysicalSize`](/reference/javascript/api/namespacedpi/#physicalsize) \| [`Size`](/reference/javascript/api/namespacedpi/#size) | The logical or physical inner size, or `null` to unset the constraint. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow, PhysicalSize } from '@tauri-apps/api/window'; await getCurrentWindow().setMinSize(new PhysicalSize(600, 500)); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setMinSize`](/reference/javascript/api/namespacewindow/#setminsize) **Source**: []() ##### setMinimizable() ```ts setMinimizable(minimizable): Promise ``` Sets whether the window’s native minimize button is enabled or not. Platform-specific * **Linux / iOS / Android:** Unsupported. ###### Parameters | Parameter | Type | | ------------- | --------- | | `minimizable` | `boolean` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setMinimizable(false); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setMinimizable`](/reference/javascript/api/namespacewindow/#setminimizable) **Source**: []() ##### setOverlayIcon() ```ts setOverlayIcon(icon?): Promise ``` Sets the overlay icon. **Windows only** The overlay icon can be set for every window. Note that you may need the `image-ico` or `image-png` Cargo features to use this API. To enable it, change your Cargo.toml file: ```toml [dependencies] tauri = { version = "...", features = ["...", "image-png"] } ``` ###### Parameters | Parameter | Type | Description | | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------- | | `icon`? | \| `string` \| [`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) \| `number`\[] \| [`ArrayBuffer`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) \| [`Image`](/reference/javascript/api/namespaceimage/#image) | Icon bytes or path to the icon file. Use `undefined` to remove the overlay icon. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setOverlayIcon("/tauri/awesome.png"); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setOverlayIcon`](/reference/javascript/api/namespacewindow/#setoverlayicon) **Source**: []() ##### setPosition() ```ts setPosition(position): Promise ``` Sets the webview position. ###### Parameters | Parameter | Type | Description | | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ | | `position` | [`LogicalPosition`](/reference/javascript/api/namespacedpi/#logicalposition) \| [`PhysicalPosition`](/reference/javascript/api/namespacedpi/#physicalposition) \| [`Position`](/reference/javascript/api/namespacedpi/#position) | The new position, in logical or physical pixels. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrent, LogicalPosition } from '@tauri-apps/api/webview'; await getCurrentWebview().setPosition(new LogicalPosition(600, 500)); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setPosition`](/reference/javascript/api/namespacewindow/#setposition) **Source**: []() ##### setProgressBar() ```ts setProgressBar(state): Promise ``` Sets the taskbar progress state. Platform-specific * **Linux / macOS**: Progress bar is app-wide and not specific to this window. * **Linux**: Only supported desktop environments with `libunity` (e.g. GNOME). ###### Parameters | Parameter | Type | | --------- | --------------------------------------------------------------------------------- | | `state` | [`ProgressBarState`](/reference/javascript/api/namespacewindow/#progressbarstate) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow, ProgressBarStatus } from '@tauri-apps/api/window'; await getCurrentWindow().setProgressBar({ status: ProgressBarStatus.Normal, progress: 50, }); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setProgressBar`](/reference/javascript/api/namespacewindow/#setprogressbar) **Source**: []() ##### setResizable() ```ts setResizable(resizable): Promise ``` Updates the window resizable flag. ###### Parameters | Parameter | Type | | ----------- | --------- | | `resizable` | `boolean` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setResizable(false); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setResizable`](/reference/javascript/api/namespacewindow/#setresizable) **Source**: []() ##### setShadow() ```ts setShadow(enable): Promise ``` Whether or not the window should have shadow. Platform-specific * **Windows:** * `false` has no effect on decorated window, shadows are always ON. * `true` will make undecorated window have a 1px white border, and on Windows 11, it will have a rounded corners. * **Linux:** Unsupported. ###### Parameters | Parameter | Type | | --------- | --------- | | `enable` | `boolean` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setShadow(false); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setShadow`](/reference/javascript/api/namespacewindow/#setshadow) **Source**: []() ##### setSimpleFullscreen() ```ts setSimpleFullscreen(fullscreen): Promise ``` On macOS, Toggles a fullscreen mode that doesn’t require a new macOS space. Returns a boolean indicating whether the transition was successful (this won’t work if the window was already in the native fullscreen). This is how fullscreen used to work on macOS in versions before Lion. And allows the user to have a fullscreen window without using another space or taking control over the entire monitor. On other platforms, this is the same as [Window.setFullscreen](/reference/javascript/api/namespacewindow/#setfullscreen). ###### Parameters | Parameter | Type | Description | | ------------ | --------- | --------------------------------------------------------- | | `fullscreen` | `boolean` | Whether the window should go to simple fullscreen or not. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setSimpleFullscreen`](/reference/javascript/api/namespacewindow/#setsimplefullscreen) **Source**: []() ##### setSize() ```ts setSize(size): Promise ``` Resizes the webview. ###### Parameters | Parameter | Type | Description | | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- | | `size` | [`LogicalSize`](/reference/javascript/api/namespacedpi/#logicalsize) \| [`PhysicalSize`](/reference/javascript/api/namespacedpi/#physicalsize) \| [`Size`](/reference/javascript/api/namespacedpi/#size) | The logical or physical size. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrent, LogicalSize } from '@tauri-apps/api/webview'; await getCurrentWebview().setSize(new LogicalSize(600, 500)); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setSize`](/reference/javascript/api/namespacewindow/#setsize) **Source**: []() ##### setSizeConstraints() ```ts setSizeConstraints(constraints): Promise ``` Sets the window inner size constraints. ###### Parameters | Parameter | Type | Description | | ------------- | -------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- | | `constraints` | `undefined` \| `null` \| [`WindowSizeConstraints`](/reference/javascript/api/namespacewindow/#windowsizeconstraints) | The logical or physical inner size, or `null` to unset the constraint. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setSizeConstraints({ minWidth: 300 }); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setSizeConstraints`](/reference/javascript/api/namespacewindow/#setsizeconstraints) **Source**: []() ##### setSkipTaskbar() ```ts setSkipTaskbar(skip): Promise ``` Whether the window icon should be hidden from the taskbar or not. Platform-specific * **macOS:** Unsupported. ###### Parameters | Parameter | Type | Description | | --------- | --------- | ------------------------------------------- | | `skip` | `boolean` | true to hide window icon, false to show it. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setSkipTaskbar(true); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setSkipTaskbar`](/reference/javascript/api/namespacewindow/#setskiptaskbar) **Source**: []() ##### setTheme() ```ts setTheme(theme?): Promise ``` Set window theme, pass in `null` or `undefined` to follow system theme Platform-specific * **Linux / macOS**: Theme is app-wide and not specific to this window. * **iOS / Android:** Unsupported. ###### Parameters | Parameter | Type | | --------- | ----------------------------------------------------------------------- | | `theme`? | `null` \| [`Theme`](/reference/javascript/api/namespacewindow/#theme-2) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Since 2.0.0 ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setTheme`](/reference/javascript/api/namespacewindow/#settheme) **Source**: []() ##### setTitle() ```ts setTitle(title): Promise ``` Sets the window title. ###### Parameters | Parameter | Type | Description | | --------- | -------- | ------------- | | `title` | `string` | The new title | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setTitle('Tauri'); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setTitle`](/reference/javascript/api/namespacewindow/#settitle) **Source**: []() ##### setTitleBarStyle() ```ts setTitleBarStyle(style): Promise ``` Sets the title bar style. **macOS only**. ###### Parameters | Parameter | Type | | --------- | ----------------------------------------------------------------------------- | | `style` | [`TitleBarStyle`](/reference/javascript/api/namespacewindow/#titlebarstyle-1) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Since 2.0.0 ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setTitleBarStyle`](/reference/javascript/api/namespacewindow/#settitlebarstyle) **Source**: []() ##### setVisibleOnAllWorkspaces() ```ts setVisibleOnAllWorkspaces(visible): Promise ``` Sets whether the window should be visible on all workspaces or virtual desktops. Platform-specific * **Windows / iOS / Android:** Unsupported. ###### Parameters | Parameter | Type | | --------- | --------- | | `visible` | `boolean` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Since 2.0.0 ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`setVisibleOnAllWorkspaces`](/reference/javascript/api/namespacewindow/#setvisibleonallworkspaces) **Source**: []() ##### setZoom() ```ts setZoom(scaleFactor): Promise ``` Set webview zoom level. ###### Parameters | Parameter | Type | | ------------- | -------- | | `scaleFactor` | `number` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWebview } from '@tauri-apps/api/webview'; await getCurrentWebview().setZoom(1.5); ``` ###### Inherited from [`Webview`](/reference/javascript/api/namespacewebview/#webview).[`setZoom`](/reference/javascript/api/namespacewebview/#setzoom) **Source**: []() ##### show() ```ts show(): Promise ``` Show the webview. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWebview } from '@tauri-apps/api/webview'; await getCurrentWebview().show(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`show`](/reference/javascript/api/namespacewindow/#show) **Source**: []() ##### size() ```ts size(): Promise ``` The physical size of the webview’s client area. The client area is the content of the webview, excluding the title bar and borders. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`PhysicalSize`](/reference/javascript/api/namespacedpi/#physicalsize)> The webview’s size. ###### Example ```typescript import { getCurrentWebview } from '@tauri-apps/api/webview'; const size = await getCurrentWebview().size(); ``` ###### Inherited from [`Webview`](/reference/javascript/api/namespacewebview/#webview).[`size`](/reference/javascript/api/namespacewebview/#size) **Source**: []() ##### startDragging() ```ts startDragging(): Promise ``` Starts dragging the window. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().startDragging(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`startDragging`](/reference/javascript/api/namespacewindow/#startdragging) **Source**: []() ##### startResizeDragging() ```ts startResizeDragging(direction): Promise ``` Starts resize-dragging the window. ###### Parameters | Parameter | Type | | ----------- | ----------------- | | `direction` | `ResizeDirection` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().startResizeDragging(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`startResizeDragging`](/reference/javascript/api/namespacewindow/#startresizedragging) **Source**: []() ##### theme() ```ts theme(): Promise ``` Gets the window’s current theme. Platform-specific * **macOS:** Theme was introduced on macOS 10.14. Returns `light` on macOS 10.13 and below. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`null` | [`Theme`](/reference/javascript/api/namespacewindow/#theme-2)> The window theme. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const theme = await getCurrentWindow().theme(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`theme`](/reference/javascript/api/namespacewindow/#theme) **Source**: []() ##### title() ```ts title(): Promise ``` Gets the window’s current title. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const title = await getCurrentWindow().title(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`title`](/reference/javascript/api/namespacewindow/#title) **Source**: []() ##### toggleMaximize() ```ts toggleMaximize(): Promise ``` Toggles the window maximized state. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().toggleMaximize(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`toggleMaximize`](/reference/javascript/api/namespacewindow/#togglemaximize) **Source**: []() ##### unmaximize() ```ts unmaximize(): Promise ``` Unmaximizes the window. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().unmaximize(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`unmaximize`](/reference/javascript/api/namespacewindow/#unmaximize) **Source**: []() ##### unminimize() ```ts unminimize(): Promise ``` Unminimizes the window. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().unminimize(); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`unminimize`](/reference/javascript/api/namespacewindow/#unminimize) **Source**: []() ##### getAll() ```ts static getAll(): Promise ``` Gets a list of instances of `Webview` for all available webviews. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`WebviewWindow`](/reference/javascript/api/namespacewebviewwindow/#webviewwindow)\[]> ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`getAll`](/reference/javascript/api/namespacewindow/#getall) **Source**: []() ##### getByLabel() ```ts static getByLabel(label): Promise ``` Gets the Webview for the webview associated with the given label. ###### Parameters | Parameter | Type | Description | | --------- | -------- | ------------------ | | `label` | `string` | The webview label. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`null` | [`WebviewWindow`](/reference/javascript/api/namespacewebviewwindow/#webviewwindow)> The Webview instance to communicate with the webview or null if the webview doesn’t exist. ###### Example ```typescript import { WebviewWindow } from '@tauri-apps/api/webviewWindow'; const mainWebview = WebviewWindow.getByLabel('main'); ``` ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`getByLabel`](/reference/javascript/api/namespacewindow/#getbylabel) **Source**: []() ##### getCurrent() ```ts static getCurrent(): WebviewWindow ``` Get an instance of `Webview` for the current webview. ###### Returns [`WebviewWindow`](/reference/javascript/api/namespacewebviewwindow/#webviewwindow) ###### Inherited from [`Window`](/reference/javascript/api/namespacewindow/#window).[`getCurrent`](/reference/javascript/api/namespacewindow/#getcurrent) **Source**: ## Functions []() ### getAllWebviewWindows() ```ts function getAllWebviewWindows(): Promise ``` Gets a list of instances of `Webview` for all available webview windows. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`WebviewWindow`](/reference/javascript/api/namespacewebviewwindow/#webviewwindow)\[]> #### Since 2.0.0 **Source**: *** []() ### getCurrentWebviewWindow() ```ts function getCurrentWebviewWindow(): WebviewWindow ``` Get an instance of `Webview` for the current webview window. #### Returns [`WebviewWindow`](/reference/javascript/api/namespacewebviewwindow/#webviewwindow) #### Since 2.0.0 **Source**: # window Provides APIs to create windows, communicate with other windows and manipulate the current window. #### Window events Events can be listened to using [Window.listen](/reference/javascript/api/namespacewindow/#listen): ```typescript import { getCurrentWindow } from "@tauri-apps/api/window"; getCurrentWindow().listen("my-window-event", ({ event, payload }) => { }); ``` ## References []() ### Color Re-exports [Color](/reference/javascript/api/namespacewebview/#color) []() ### DragDropEvent Re-exports [DragDropEvent](/reference/javascript/api/namespacewebview/#dragdropevent) []() ### LogicalPosition Re-exports [LogicalPosition](/reference/javascript/api/namespacedpi/#logicalposition) []() ### LogicalSize Re-exports [LogicalSize](/reference/javascript/api/namespacedpi/#logicalsize) []() ### PhysicalPosition Re-exports [PhysicalPosition](/reference/javascript/api/namespacedpi/#physicalposition) []() ### PhysicalSize Re-exports [PhysicalSize](/reference/javascript/api/namespacedpi/#physicalsize) ## Enumerations []() ### BackgroundThrottlingPolicy Background throttling policy #### Since 2.0.0 #### Enumeration Members []() ##### Disabled ```ts Disabled: "disabled"; ``` **Source**: []() ##### Suspend ```ts Suspend: "suspend"; ``` **Source**: []() ##### Throttle ```ts Throttle: "throttle"; ``` **Source**: *** []() ### Effect Platform-specific window effects #### Since 2.0.0 #### Enumeration Members []() ##### Acrylic ```ts Acrylic: "acrylic"; ``` **Windows 10/11** #### Notes This effect has bad performance when resizing/dragging the window on Windows 10 v1903+ and Windows 11 build 22000. **Source**: []() ##### ~~AppearanceBased~~ ```ts AppearanceBased: "appearanceBased"; ``` A default material appropriate for the view’s effectiveAppearance. **macOS 10.14-** ###### Deprecated since macOS 10.14. You should instead choose an appropriate semantic material. **Source**: []() ##### Blur ```ts Blur: "blur"; ``` **Windows 7/10/11(22H1) Only** #### Notes This effect has bad performance when resizing/dragging the window on Windows 11 build 22621. **Source**: []() ##### ContentBackground ```ts ContentBackground: "contentBackground"; ``` **macOS 10.14+** **Source**: []() ##### ~~Dark~~ ```ts Dark: "dark"; ``` **macOS 10.14-** ###### Deprecated since macOS 10.14. Use a semantic material instead. **Source**: []() ##### FullScreenUI ```ts FullScreenUI: "fullScreenUI"; ``` **macOS 10.14+** **Source**: []() ##### HeaderView ```ts HeaderView: "headerView"; ``` **macOS 10.14+** **Source**: []() ##### HudWindow ```ts HudWindow: "hudWindow"; ``` **macOS 10.14+** **Source**: []() ##### ~~Light~~ ```ts Light: "light"; ``` **macOS 10.14-** ###### Deprecated since macOS 10.14. Use a semantic material instead. **Source**: []() ##### ~~MediumLight~~ ```ts MediumLight: "mediumLight"; ``` **macOS 10.14-** ###### Deprecated since macOS 10.14. Use a semantic material instead. **Source**: []() ##### Menu ```ts Menu: "menu"; ``` **macOS 10.11+** **Source**: []() ##### Mica ```ts Mica: "mica"; ``` **Windows 11 Only** **Source**: []() ##### Popover ```ts Popover: "popover"; ``` **macOS 10.11+** **Source**: []() ##### Selection ```ts Selection: "selection"; ``` **macOS 10.10+** **Source**: []() ##### Sheet ```ts Sheet: "sheet"; ``` **macOS 10.14+** **Source**: []() ##### Sidebar ```ts Sidebar: "sidebar"; ``` **macOS 10.11+** **Source**: []() ##### Tabbed ```ts Tabbed: "tabbed"; ``` Tabbed effect that matches the system dark preference **Windows 11 Only** **Source**: []() ##### TabbedDark ```ts TabbedDark: "tabbedDark"; ``` Tabbed effect with dark mode but only if dark mode is enabled on the system **Windows 11 Only** **Source**: []() ##### TabbedLight ```ts TabbedLight: "tabbedLight"; ``` Tabbed effect with light mode **Windows 11 Only** **Source**: []() ##### Titlebar ```ts Titlebar: "titlebar"; ``` **macOS 10.10+** **Source**: []() ##### Tooltip ```ts Tooltip: "tooltip"; ``` **macOS 10.14+** **Source**: []() ##### ~~UltraDark~~ ```ts UltraDark: "ultraDark"; ``` **macOS 10.14-** ###### Deprecated since macOS 10.14. Use a semantic material instead. **Source**: []() ##### UnderPageBackground ```ts UnderPageBackground: "underPageBackground"; ``` **macOS 10.14+** **Source**: []() ##### UnderWindowBackground ```ts UnderWindowBackground: "underWindowBackground"; ``` **macOS 10.14+** **Source**: []() ##### WindowBackground ```ts WindowBackground: "windowBackground"; ``` **macOS 10.14+** **Source**: *** []() ### EffectState Window effect state **macOS only** #### See #### Since 2.0.0 #### Enumeration Members []() ##### Active ```ts Active: "active"; ``` Make window effect state always active **macOS only** **Source**: []() ##### FollowsWindowActiveState ```ts FollowsWindowActiveState: "followsWindowActiveState"; ``` Make window effect state follow the window’s active state **macOS only** **Source**: []() ##### Inactive ```ts Inactive: "inactive"; ``` Make window effect state always inactive **macOS only** **Source**: *** []() ### ProgressBarStatus #### Enumeration Members []() ##### Error ```ts Error: "error"; ``` Error state. **Treated as Normal on linux** **Source**: []() ##### Indeterminate ```ts Indeterminate: "indeterminate"; ``` Indeterminate state. **Treated as Normal on Linux and macOS** **Source**: []() ##### None ```ts None: "none"; ``` Hide progress bar. **Source**: []() ##### Normal ```ts Normal: "normal"; ``` Normal state. **Source**: []() ##### Paused ```ts Paused: "paused"; ``` Paused state. **Treated as Normal on Linux** **Source**: *** []() ### ScrollBarStyle The scrollbar style to use in the webview. ## Platform-specific **Windows**: This option must be given the same value for all webviews. #### Since 2.8.0 #### Enumeration Members []() ##### Default ```ts Default: "default"; ``` The default scrollbar style for the webview. **Source**: []() ##### FluentOverlay ```ts FluentOverlay: "fluentOverlay"; ``` Fluent UI style overlay scrollbars. **Windows Only** Requires WebView2 Runtime version 125.0.2535.41 or higher, does nothing on older versions, see **Source**: *** []() ### UserAttentionType Attention type to request on a window. #### Since 1.0.0 #### Enumeration Members []() ##### Critical ```ts Critical: 1; ``` Platform-specific * **macOS:** Bounces the dock icon until the application is in focus. * **Windows:** Flashes both the window and the taskbar button until the application is in focus. **Source**: []() ##### Informational ```ts Informational: 2; ``` Platform-specific * **macOS:** Bounces the dock icon once. * **Windows:** Flashes the taskbar button until the application is in focus. **Source**: ## Classes []() ### CloseRequestedEvent #### Constructors []() ##### new CloseRequestedEvent() ```ts new CloseRequestedEvent(event): CloseRequestedEvent ``` ###### Parameters | Parameter | Type | | --------- | ---------------------------------------------------------------------- | | `event` | [`Event`](/reference/javascript/api/namespaceevent/#eventt)<`unknown`> | ###### Returns [`CloseRequestedEvent`](/reference/javascript/api/namespacewindow/#closerequestedevent) **Source**: #### Properties | Property | Type | Description | Defined in | | ----------- | ------------------------------------------------------------------ | --------------------------------- | ------------------------------------------------------------------------------------------ | | []()`event` | [`EventName`](/reference/javascript/api/namespaceevent/#eventname) | Event name | **Source**: | | []()`id` | `number` | Event identifier used to unlisten | **Source**: | #### Methods []() ##### isPreventDefault() ```ts isPreventDefault(): boolean ``` ###### Returns `boolean` **Source**: []() ##### preventDefault() ```ts preventDefault(): void ``` ###### Returns `void` **Source**: *** []() ### Window Create new window or get a handle to an existing one. Windows are identified by a *label* a unique identifier that can be used to reference it later. It may only contain alphanumeric characters `a-zA-Z` plus the following special characters `-`, `/`, `:` and `_`. #### Example ```typescript import { Window } from "@tauri-apps/api/window" const appWindow = new Window('theUniqueLabel'); appWindow.once('tauri://created', function () { // window successfully created }); appWindow.once('tauri://error', function (e) { // an error happened creating the window }); // emit an event to the backend await appWindow.emit("some-event", "data"); // listen to an event from the backend const unlisten = await appWindow.listen("event-name", e => {}); unlisten(); ``` #### Since 2.0.0 #### Extended by * [`WebviewWindow`](/reference/javascript/api/namespacewebviewwindow/#webviewwindow) #### Constructors []() ##### new Window() ```ts new Window(label, options): Window ``` Creates a new Window. ###### Parameters | Parameter | Type | Description | | --------- | --------------------------------------------------------------------------- | ------------------------------------------------------------ | | `label` | `string` | The unique window label. Must be alphanumeric: `a-zA-Z-/:_`. | | `options` | [`WindowOptions`](/reference/javascript/api/namespacewindow/#windowoptions) | - | ###### Returns [`Window`](/reference/javascript/api/namespacewindow/#window) The [Window](/reference/javascript/api/namespacewindow/#window) instance to communicate with the window. ###### Example ```typescript import { Window } from '@tauri-apps/api/window'; const appWindow = new Window('my-label'); appWindow.once('tauri://created', function () { // window successfully created }); appWindow.once('tauri://error', function (e) { // an error happened creating the window }); ``` **Source**: #### Properties | Property | Type | Description | Defined in | | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ | | []()`label` | `string` | The window label. It is a unique identifier for the window, can be used to reference it later. | **Source**: | | []()`listeners` | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)<`string`, [`EventCallback`](/reference/javascript/api/namespaceevent/#eventcallbackt)<`any`>\[]> | Local event listeners. | **Source**: | #### Methods []() ##### activityName() ```ts activityName(): Promise ``` ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> **Source**: []() ##### center() ```ts center(): Promise ``` Centers the window. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().center(); ``` **Source**: []() ##### clearEffects() ```ts clearEffects(): Promise ``` Clear any applied effects if possible. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### close() ```ts close(): Promise ``` Closes the window. Note this emits a closeRequested event so you can intercept it. To force window close, use [Window.destroy](/reference/javascript/api/namespacewindow/#destroy). ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().close(); ``` **Source**: []() ##### destroy() ```ts destroy(): Promise ``` Destroys the window. Behaves like [Window.close](/reference/javascript/api/namespacewindow/#close) but forces the window close instead of emitting a closeRequested event. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().destroy(); ``` **Source**: []() ##### emit() ```ts emit(event, payload?): Promise ``` Emits an event to all [targets](/reference/javascript/api/namespaceevent/#eventtarget). ###### Type Parameters | Type Parameter | | -------------- | | `T` | ###### Parameters | Parameter | Type | Description | | ---------- | -------- | ----------------------------------------------------------------------------- | | `event` | `string` | Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`. | | `payload`? | `T` | Event payload. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().emit('window-loaded', { loggedIn: true, token: 'authToken' }); ``` **Source**: []() ##### emitTo() ```ts emitTo( target, event, payload?): Promise ``` Emits an event to all [targets](/reference/javascript/api/namespaceevent/#eventtarget) matching the given target. ###### Type Parameters | Type Parameter | | -------------- | | `T` | ###### Parameters | Parameter | Type | Description | | ---------- | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | | `target` | `string` \| [`EventTarget`](/reference/javascript/api/namespaceevent/#eventtarget) | Label of the target Window/Webview/WebviewWindow or raw [EventTarget](/reference/javascript/api/namespaceevent/#eventtarget) object. | | `event` | `string` | Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`. | | `payload`? | `T` | Event payload. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().emit('main', 'window-loaded', { loggedIn: true, token: 'authToken' }); ``` **Source**: []() ##### hide() ```ts hide(): Promise ``` Sets the window visibility to false. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().hide(); ``` **Source**: []() ##### innerPosition() ```ts innerPosition(): Promise ``` The position of the top-left hand corner of the window’s client area relative to the top-left hand corner of the desktop. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`PhysicalPosition`](/reference/javascript/api/namespacedpi/#physicalposition)> The window’s inner position. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const position = await getCurrentWindow().innerPosition(); ``` **Source**: []() ##### innerSize() ```ts innerSize(): Promise ``` The physical size of the window’s client area. The client area is the content of the window, excluding the title bar and borders. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`PhysicalSize`](/reference/javascript/api/namespacedpi/#physicalsize)> The window’s inner size. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const size = await getCurrentWindow().innerSize(); ``` **Source**: []() ##### isAlwaysOnTop() ```ts isAlwaysOnTop(): Promise ``` Whether the window is configured to be always on top of other windows or not. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> Whether the window is visible or not. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const alwaysOnTop = await getCurrentWindow().isAlwaysOnTop(); ``` **Source**: []() ##### isClosable() ```ts isClosable(): Promise ``` Gets the window’s native close button state. Platform-specific * **iOS / Android:** Unsupported. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> Whether the window’s native close button is enabled or not. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const closable = await getCurrentWindow().isClosable(); ``` **Source**: []() ##### isDecorated() ```ts isDecorated(): Promise ``` Gets the window’s current decorated state. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> Whether the window is decorated or not. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const decorated = await getCurrentWindow().isDecorated(); ``` **Source**: []() ##### isEnabled() ```ts isEnabled(): Promise ``` Whether the window is enabled or disabled. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setEnabled(false); ``` ###### Since 2.0.0 **Source**: []() ##### isFocused() ```ts isFocused(): Promise ``` Gets the window’s current focus state. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> Whether the window is focused or not. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const focused = await getCurrentWindow().isFocused(); ``` **Source**: []() ##### isFullscreen() ```ts isFullscreen(): Promise ``` Gets the window’s current fullscreen state. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> Whether the window is in fullscreen mode or not. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const fullscreen = await getCurrentWindow().isFullscreen(); ``` **Source**: []() ##### isMaximizable() ```ts isMaximizable(): Promise ``` Gets the window’s native maximize button state. Platform-specific * **Linux / iOS / Android:** Unsupported. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> Whether the window’s native maximize button is enabled or not. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const maximizable = await getCurrentWindow().isMaximizable(); ``` **Source**: []() ##### isMaximized() ```ts isMaximized(): Promise ``` Gets the window’s current maximized state. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> Whether the window is maximized or not. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const maximized = await getCurrentWindow().isMaximized(); ``` **Source**: []() ##### isMinimizable() ```ts isMinimizable(): Promise ``` Gets the window’s native minimize button state. Platform-specific * **Linux / iOS / Android:** Unsupported. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> Whether the window’s native minimize button is enabled or not. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const minimizable = await getCurrentWindow().isMinimizable(); ``` **Source**: []() ##### isMinimized() ```ts isMinimized(): Promise ``` Gets the window’s current minimized state. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const minimized = await getCurrentWindow().isMinimized(); ``` **Source**: []() ##### isResizable() ```ts isResizable(): Promise ``` Gets the window’s current resizable state. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> Whether the window is resizable or not. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const resizable = await getCurrentWindow().isResizable(); ``` **Source**: []() ##### isVisible() ```ts isVisible(): Promise ``` Gets the window’s current visible state. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> Whether the window is visible or not. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const visible = await getCurrentWindow().isVisible(); ``` **Source**: []() ##### listen() ```ts listen(event, handler): Promise ``` Listen to an emitted event on this window. ###### Type Parameters | Type Parameter | | -------------- | | `T` | ###### Parameters | Parameter | Type | Description | | --------- | -------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | | `event` | [`EventName`](/reference/javascript/api/namespaceevent/#eventname) | Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`. | | `handler` | [`EventCallback`](/reference/javascript/api/namespaceevent/#eventcallbackt)<`T`> | Event handler. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`UnlistenFn`](/reference/javascript/api/namespaceevent/#unlistenfn)> A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const unlisten = await getCurrentWindow().listen('state-changed', (event) => { console.log(`Got error: ${payload}`); }); // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted unlisten(); ``` **Source**: []() ##### maximize() ```ts maximize(): Promise ``` Maximizes the window. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().maximize(); ``` **Source**: []() ##### minimize() ```ts minimize(): Promise ``` Minimizes the window. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().minimize(); ``` **Source**: []() ##### onCloseRequested() ```ts onCloseRequested(handler): Promise ``` Listen to window close requested. Emitted when the user requests to closes the window. ###### Parameters | Parameter | Type | | --------- | ------------------------------------------------------------------------------------------------------------------------------ | | `handler` | (`event`) => `void` \| [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`UnlistenFn`](/reference/javascript/api/namespaceevent/#unlistenfn)> A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted. ###### Example ```typescript import { getCurrentWindow } from "@tauri-apps/api/window"; import { confirm } from '@tauri-apps/api/dialog'; const unlisten = await getCurrentWindow().onCloseRequested(async (event) => { const confirmed = await confirm('Are you sure?'); if (!confirmed) { // user did not confirm closing the window; let's prevent it event.preventDefault(); } }); // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted unlisten(); ``` **Source**: []() ##### onDragDropEvent() ```ts onDragDropEvent(handler): Promise ``` Listen to a file drop event. The listener is triggered when the user hovers the selected files on the webview, drops the files or cancels the operation. ###### Parameters | Parameter | Type | | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | | `handler` | [`EventCallback`](/reference/javascript/api/namespaceevent/#eventcallbackt)<[`DragDropEvent`](/reference/javascript/api/namespacewebview/#dragdropevent)> | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`UnlistenFn`](/reference/javascript/api/namespaceevent/#unlistenfn)> A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted. ###### Example ```typescript import { getCurrentWindow } from "@tauri-apps/api/webview"; const unlisten = await getCurrentWindow().onDragDropEvent((event) => { if (event.payload.type === 'over') { console.log('User hovering', event.payload.position); } else if (event.payload.type === 'drop') { console.log('User dropped', event.payload.paths); } else { console.log('File drop cancelled'); } }); // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted unlisten(); ``` **Source**: []() ##### onFocusChanged() ```ts onFocusChanged(handler): Promise ``` Listen to window focus change. ###### Parameters | Parameter | Type | | --------- | -------------------------------------------------------------------------------------- | | `handler` | [`EventCallback`](/reference/javascript/api/namespaceevent/#eventcallbackt)<`boolean`> | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`UnlistenFn`](/reference/javascript/api/namespaceevent/#unlistenfn)> A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted. ###### Example ```typescript import { getCurrentWindow } from "@tauri-apps/api/window"; const unlisten = await getCurrentWindow().onFocusChanged(({ payload: focused }) => { console.log('Focus changed, window is focused? ' + focused); }); // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted unlisten(); ``` **Source**: []() ##### onMoved() ```ts onMoved(handler): Promise ``` Listen to window move. ###### Parameters | Parameter | Type | | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | | `handler` | [`EventCallback`](/reference/javascript/api/namespaceevent/#eventcallbackt)<[`PhysicalPosition`](/reference/javascript/api/namespacedpi/#physicalposition)> | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`UnlistenFn`](/reference/javascript/api/namespaceevent/#unlistenfn)> A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted. ###### Example ```typescript import { getCurrentWindow } from "@tauri-apps/api/window"; const unlisten = await getCurrentWindow().onMoved(({ payload: position }) => { console.log('Window moved', position); }); // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted unlisten(); ``` **Source**: []() ##### onResized() ```ts onResized(handler): Promise ``` Listen to window resize. ###### Parameters | Parameter | Type | | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | | `handler` | [`EventCallback`](/reference/javascript/api/namespaceevent/#eventcallbackt)<[`PhysicalSize`](/reference/javascript/api/namespacedpi/#physicalsize)> | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`UnlistenFn`](/reference/javascript/api/namespaceevent/#unlistenfn)> A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted. ###### Example ```typescript import { getCurrentWindow } from "@tauri-apps/api/window"; const unlisten = await getCurrentWindow().onResized(({ payload: size }) => { console.log('Window resized', size); }); // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted unlisten(); ``` **Source**: []() ##### onScaleChanged() ```ts onScaleChanged(handler): Promise ``` Listen to window scale change. Emitted when the window’s scale factor has changed. The following user actions can cause DPI changes: * Changing the display’s resolution. * Changing the display’s scale factor (e.g. in Control Panel on Windows). * Moving the window to a display with a different scale factor. ###### Parameters | Parameter | Type | | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `handler` | [`EventCallback`](/reference/javascript/api/namespaceevent/#eventcallbackt)<[`ScaleFactorChanged`](/reference/javascript/api/namespacewindow/#scalefactorchanged)> | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`UnlistenFn`](/reference/javascript/api/namespaceevent/#unlistenfn)> A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted. ###### Example ```typescript import { getCurrentWindow } from "@tauri-apps/api/window"; const unlisten = await getCurrentWindow().onScaleChanged(({ payload }) => { console.log('Scale changed', payload.scaleFactor, payload.size); }); // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted unlisten(); ``` **Source**: []() ##### onThemeChanged() ```ts onThemeChanged(handler): Promise ``` Listen to the system theme change. ###### Parameters | Parameter | Type | | --------- | ------------------------------------------------------------------------------------------------------------------------------------------ | | `handler` | [`EventCallback`](/reference/javascript/api/namespaceevent/#eventcallbackt)<[`Theme`](/reference/javascript/api/namespacewindow/#theme-2)> | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`UnlistenFn`](/reference/javascript/api/namespaceevent/#unlistenfn)> A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted. ###### Example ```typescript import { getCurrentWindow } from "@tauri-apps/api/window"; const unlisten = await getCurrentWindow().onThemeChanged(({ payload: theme }) => { console.log('New theme: ' + theme); }); // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted unlisten(); ``` **Source**: []() ##### once() ```ts once(event, handler): Promise ``` Listen to an emitted event on this window only once. ###### Type Parameters | Type Parameter | | -------------- | | `T` | ###### Parameters | Parameter | Type | Description | | --------- | -------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | | `event` | [`EventName`](/reference/javascript/api/namespaceevent/#eventname) | Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`. | | `handler` | [`EventCallback`](/reference/javascript/api/namespaceevent/#eventcallbackt)<`T`> | Event handler. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`UnlistenFn`](/reference/javascript/api/namespaceevent/#unlistenfn)> A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const unlisten = await getCurrentWindow().once('initialized', (event) => { console.log(`Window initialized!`); }); // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted unlisten(); ``` **Source**: []() ##### outerPosition() ```ts outerPosition(): Promise ``` The position of the top-left hand corner of the window relative to the top-left hand corner of the desktop. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`PhysicalPosition`](/reference/javascript/api/namespacedpi/#physicalposition)> The window’s outer position. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const position = await getCurrentWindow().outerPosition(); ``` **Source**: []() ##### outerSize() ```ts outerSize(): Promise ``` The physical size of the entire window. These dimensions include the title bar and borders. If you don’t want that (and you usually don’t), use inner\_size instead. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`PhysicalSize`](/reference/javascript/api/namespacedpi/#physicalsize)> The window’s outer size. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const size = await getCurrentWindow().outerSize(); ``` **Source**: []() ##### requestUserAttention() ```ts requestUserAttention(requestType): Promise ``` Requests user attention to the window, this has no effect if the application is already focused. How requesting for user attention manifests is platform dependent, see `UserAttentionType` for details. Providing `null` will unset the request for user attention. Unsetting the request for user attention might not be done automatically by the WM when the window receives input. Platform-specific * **macOS:** `null` has no effect. * **Linux:** Urgency levels have the same effect. ###### Parameters | Parameter | Type | | ------------- | --------------------------------------------------------------------------------------------- | | `requestType` | `null` \| [`UserAttentionType`](/reference/javascript/api/namespacewindow/#userattentiontype) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().requestUserAttention(); ``` **Source**: []() ##### scaleFactor() ```ts scaleFactor(): Promise ``` The scale factor that can be used to map physical pixels to logical pixels. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`number`> The window’s monitor scale factor. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const factor = await getCurrentWindow().scaleFactor(); ``` **Source**: []() ##### sceneIdentifier() ```ts sceneIdentifier(): Promise ``` ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> **Source**: []() ##### setAlwaysOnBottom() ```ts setAlwaysOnBottom(alwaysOnBottom): Promise ``` Whether the window should always be below other windows. ###### Parameters | Parameter | Type | Description | | ---------------- | --------- | --------------------------------------------------------------- | | `alwaysOnBottom` | `boolean` | Whether the window should always be below other windows or not. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setAlwaysOnBottom(true); ``` **Source**: []() ##### setAlwaysOnTop() ```ts setAlwaysOnTop(alwaysOnTop): Promise ``` Whether the window should always be on top of other windows. ###### Parameters | Parameter | Type | Description | | ------------- | --------- | ------------------------------------------------------------------- | | `alwaysOnTop` | `boolean` | Whether the window should always be on top of other windows or not. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setAlwaysOnTop(true); ``` **Source**: []() ##### setBackgroundColor() ```ts setBackgroundColor(color): Promise ``` Sets the window background color. Platform-specific: * **Windows:** alpha channel is ignored. * **iOS / Android:** Unsupported. ###### Parameters | Parameter | Type | | --------- | ------------------------------------------------------------ | | `color` | [`Color`](/reference/javascript/api/namespacewebview/#color) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Since 2.1.0 **Source**: []() ##### setBadgeCount() ```ts setBadgeCount(count?): Promise ``` Sets the badge count. It is app wide and not specific to this window. Platform-specific * **Windows**: Unsupported. Use @{linkcode Window\.setOverlayIcon} instead. ###### Parameters | Parameter | Type | Description | | --------- | -------- | ----------------------------------------------------- | | `count`? | `number` | The badge count. Use `undefined` to remove the badge. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setBadgeCount(5); ``` **Source**: []() ##### setBadgeLabel() ```ts setBadgeLabel(label?): Promise ``` Sets the badge cont **macOS only**. ###### Parameters | Parameter | Type | Description | | --------- | -------- | ----------------------------------------------------- | | `label`? | `string` | The badge label. Use `undefined` to remove the badge. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setBadgeLabel("Hello"); ``` **Source**: []() ##### setClosable() ```ts setClosable(closable): Promise ``` Sets whether the window’s native close button is enabled or not. Platform-specific * **Linux:** GTK+ will do its best to convince the window manager not to show a close button. Depending on the system, this function may not have any effect when called on a window that is already visible * **iOS / Android:** Unsupported. ###### Parameters | Parameter | Type | | ---------- | --------- | | `closable` | `boolean` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setClosable(false); ``` **Source**: []() ##### setContentProtected() ```ts setContentProtected(protected_): Promise ``` Prevents the window contents from being captured by other apps. ###### Parameters | Parameter | Type | | ------------ | --------- | | `protected_` | `boolean` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setContentProtected(true); ``` **Source**: []() ##### setCursorGrab() ```ts setCursorGrab(grab): Promise ``` Grabs the cursor, preventing it from leaving the window. There’s no guarantee that the cursor will be hidden. You should hide it by yourself if you want so. Platform-specific * **Linux:** Unsupported. * **macOS:** This locks the cursor in a fixed location, which looks visually awkward. ###### Parameters | Parameter | Type | Description | | --------- | --------- | ------------------------------------------------------ | | `grab` | `boolean` | `true` to grab the cursor icon, `false` to release it. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setCursorGrab(true); ``` **Source**: []() ##### setCursorIcon() ```ts setCursorIcon(icon): Promise ``` Modifies the cursor icon of the window. ###### Parameters | Parameter | Type | Description | | --------- | --------------------------------------------------------------------- | -------------------- | | `icon` | [`CursorIcon`](/reference/javascript/api/namespacewindow/#cursoricon) | The new cursor icon. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setCursorIcon('help'); ``` **Source**: []() ##### setCursorPosition() ```ts setCursorPosition(position): Promise ``` Changes the position of the cursor in window coordinates. ###### Parameters | Parameter | Type | Description | | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------ | | `position` | [`LogicalPosition`](/reference/javascript/api/namespacedpi/#logicalposition) \| [`PhysicalPosition`](/reference/javascript/api/namespacedpi/#physicalposition) \| [`Position`](/reference/javascript/api/namespacedpi/#position) | The new cursor position. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow, LogicalPosition } from '@tauri-apps/api/window'; await getCurrentWindow().setCursorPosition(new LogicalPosition(600, 300)); ``` **Source**: []() ##### setCursorVisible() ```ts setCursorVisible(visible): Promise ``` Modifies the cursor’s visibility. Platform-specific * **Windows:** The cursor is only hidden within the confines of the window. * **macOS:** The cursor is hidden as long as the window has input focus, even if the cursor is outside of the window. ###### Parameters | Parameter | Type | Description | | --------- | --------- | ---------------------------------------------------------------------------- | | `visible` | `boolean` | If `false`, this will hide the cursor. If `true`, this will show the cursor. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setCursorVisible(false); ``` **Source**: []() ##### setDecorations() ```ts setDecorations(decorations): Promise ``` Whether the window should have borders and bars. ###### Parameters | Parameter | Type | Description | | ------------- | --------- | ------------------------------------------------ | | `decorations` | `boolean` | Whether the window should have borders and bars. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setDecorations(false); ``` **Source**: []() ##### setEffects() ```ts setEffects(effects): Promise ``` Set window effects. ###### Parameters | Parameter | Type | | --------- | --------------------------------------------------------------- | | `effects` | [`Effects`](/reference/javascript/api/namespacewindow/#effects) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### setEnabled() ```ts setEnabled(enabled): Promise ``` Enable or disable the window. ###### Parameters | Parameter | Type | | --------- | --------- | | `enabled` | `boolean` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setEnabled(false); ``` ###### Since 2.0.0 **Source**: []() ##### setFocus() ```ts setFocus(): Promise ``` Bring the window to front and focus. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setFocus(); ``` **Source**: []() ##### setFocusable() ```ts setFocusable(focusable): Promise ``` Sets whether the window can be focused. Platform-specific * **macOS**: If the window is already focused, it is not possible to unfocus it after calling `set_focusable(false)`. In this case, you might consider calling [Window.setFocus](/reference/javascript/api/namespacewindow/#setfocus) but it will move the window to the back i.e. at the bottom in terms of z-order. ###### Parameters | Parameter | Type | Description | | ----------- | --------- | ---------------------------------- | | `focusable` | `boolean` | Whether the window can be focused. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setFocusable(true); ``` **Source**: []() ##### setFullscreen() ```ts setFullscreen(fullscreen): Promise ``` Sets the window fullscreen state. ###### Parameters | Parameter | Type | Description | | ------------ | --------- | -------------------------------------------------- | | `fullscreen` | `boolean` | Whether the window should go to fullscreen or not. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setFullscreen(true); ``` **Source**: []() ##### setIcon() ```ts setIcon(icon): Promise ``` Sets the window icon. ###### Parameters | Parameter | Type | Description | | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------ | | `icon` | \| `string` \| [`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) \| `number`\[] \| [`ArrayBuffer`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) \| [`Image`](/reference/javascript/api/namespaceimage/#image) | Icon bytes or path to the icon file. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setIcon('/tauri/awesome.png'); ``` Note that you may need the `image-ico` or `image-png` Cargo features to use this API. To enable it, change your Cargo.toml file: ```toml [dependencies] tauri = { version = "...", features = ["...", "image-png"] } ``` **Source**: []() ##### setIgnoreCursorEvents() ```ts setIgnoreCursorEvents(ignore): Promise ``` Changes the cursor events behavior. ###### Parameters | Parameter | Type | Description | | --------- | --------- | --------------------------------------------------------------------- | | `ignore` | `boolean` | `true` to ignore the cursor events; `false` to process them as usual. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setIgnoreCursorEvents(true); ``` **Source**: []() ##### setMaxSize() ```ts setMaxSize(size): Promise ``` Sets the window maximum inner size. If the `size` argument is undefined, the constraint is unset. ###### Parameters | Parameter | Type | Description | | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------- | | `size` | \| `undefined` \| `null` \| [`LogicalSize`](/reference/javascript/api/namespacedpi/#logicalsize) \| [`PhysicalSize`](/reference/javascript/api/namespacedpi/#physicalsize) \| [`Size`](/reference/javascript/api/namespacedpi/#size) | The logical or physical inner size, or `null` to unset the constraint. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow, LogicalSize } from '@tauri-apps/api/window'; await getCurrentWindow().setMaxSize(new LogicalSize(600, 500)); ``` **Source**: []() ##### setMaximizable() ```ts setMaximizable(maximizable): Promise ``` Sets whether the window’s native maximize button is enabled or not. If resizable is set to false, this setting is ignored. Platform-specific * **macOS:** Disables the “zoom” button in the window titlebar, which is also used to enter fullscreen mode. * **Linux / iOS / Android:** Unsupported. ###### Parameters | Parameter | Type | | ------------- | --------- | | `maximizable` | `boolean` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setMaximizable(false); ``` **Source**: []() ##### setMinSize() ```ts setMinSize(size): Promise ``` Sets the window minimum inner size. If the `size` argument is not provided, the constraint is unset. ###### Parameters | Parameter | Type | Description | | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------- | | `size` | \| `undefined` \| `null` \| [`LogicalSize`](/reference/javascript/api/namespacedpi/#logicalsize) \| [`PhysicalSize`](/reference/javascript/api/namespacedpi/#physicalsize) \| [`Size`](/reference/javascript/api/namespacedpi/#size) | The logical or physical inner size, or `null` to unset the constraint. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow, PhysicalSize } from '@tauri-apps/api/window'; await getCurrentWindow().setMinSize(new PhysicalSize(600, 500)); ``` **Source**: []() ##### setMinimizable() ```ts setMinimizable(minimizable): Promise ``` Sets whether the window’s native minimize button is enabled or not. Platform-specific * **Linux / iOS / Android:** Unsupported. ###### Parameters | Parameter | Type | | ------------- | --------- | | `minimizable` | `boolean` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setMinimizable(false); ``` **Source**: []() ##### setOverlayIcon() ```ts setOverlayIcon(icon?): Promise ``` Sets the overlay icon. **Windows only** The overlay icon can be set for every window. Note that you may need the `image-ico` or `image-png` Cargo features to use this API. To enable it, change your Cargo.toml file: ```toml [dependencies] tauri = { version = "...", features = ["...", "image-png"] } ``` ###### Parameters | Parameter | Type | Description | | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------- | | `icon`? | \| `string` \| [`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) \| `number`\[] \| [`ArrayBuffer`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) \| [`Image`](/reference/javascript/api/namespaceimage/#image) | Icon bytes or path to the icon file. Use `undefined` to remove the overlay icon. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setOverlayIcon("/tauri/awesome.png"); ``` **Source**: []() ##### setPosition() ```ts setPosition(position): Promise ``` Sets the window outer position. ###### Parameters | Parameter | Type | Description | | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ | | `position` | [`LogicalPosition`](/reference/javascript/api/namespacedpi/#logicalposition) \| [`PhysicalPosition`](/reference/javascript/api/namespacedpi/#physicalposition) \| [`Position`](/reference/javascript/api/namespacedpi/#position) | The new position, in logical or physical pixels. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow, LogicalPosition } from '@tauri-apps/api/window'; await getCurrentWindow().setPosition(new LogicalPosition(600, 500)); ``` **Source**: []() ##### setProgressBar() ```ts setProgressBar(state): Promise ``` Sets the taskbar progress state. Platform-specific * **Linux / macOS**: Progress bar is app-wide and not specific to this window. * **Linux**: Only supported desktop environments with `libunity` (e.g. GNOME). ###### Parameters | Parameter | Type | | --------- | --------------------------------------------------------------------------------- | | `state` | [`ProgressBarState`](/reference/javascript/api/namespacewindow/#progressbarstate) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow, ProgressBarStatus } from '@tauri-apps/api/window'; await getCurrentWindow().setProgressBar({ status: ProgressBarStatus.Normal, progress: 50, }); ``` **Source**: []() ##### setResizable() ```ts setResizable(resizable): Promise ``` Updates the window resizable flag. ###### Parameters | Parameter | Type | | ----------- | --------- | | `resizable` | `boolean` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setResizable(false); ``` **Source**: []() ##### setShadow() ```ts setShadow(enable): Promise ``` Whether or not the window should have shadow. Platform-specific * **Windows:** * `false` has no effect on decorated window, shadows are always ON. * `true` will make undecorated window have a 1px white border, and on Windows 11, it will have a rounded corners. * **Linux:** Unsupported. ###### Parameters | Parameter | Type | | --------- | --------- | | `enable` | `boolean` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setShadow(false); ``` **Source**: []() ##### setSimpleFullscreen() ```ts setSimpleFullscreen(fullscreen): Promise ``` On macOS, Toggles a fullscreen mode that doesn’t require a new macOS space. Returns a boolean indicating whether the transition was successful (this won’t work if the window was already in the native fullscreen). This is how fullscreen used to work on macOS in versions before Lion. And allows the user to have a fullscreen window without using another space or taking control over the entire monitor. On other platforms, this is the same as [Window.setFullscreen](/reference/javascript/api/namespacewindow/#setfullscreen). ###### Parameters | Parameter | Type | Description | | ------------ | --------- | --------------------------------------------------------- | | `fullscreen` | `boolean` | Whether the window should go to simple fullscreen or not. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. **Source**: []() ##### setSize() ```ts setSize(size): Promise ``` Resizes the window with a new inner size. ###### Parameters | Parameter | Type | Description | | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------- | | `size` | [`LogicalSize`](/reference/javascript/api/namespacedpi/#logicalsize) \| [`PhysicalSize`](/reference/javascript/api/namespacedpi/#physicalsize) \| [`Size`](/reference/javascript/api/namespacedpi/#size) | The logical or physical inner size. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow, LogicalSize } from '@tauri-apps/api/window'; await getCurrentWindow().setSize(new LogicalSize(600, 500)); ``` **Source**: []() ##### setSizeConstraints() ```ts setSizeConstraints(constraints): Promise ``` Sets the window inner size constraints. ###### Parameters | Parameter | Type | Description | | ------------- | -------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- | | `constraints` | `undefined` \| `null` \| [`WindowSizeConstraints`](/reference/javascript/api/namespacewindow/#windowsizeconstraints) | The logical or physical inner size, or `null` to unset the constraint. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setSizeConstraints({ minWidth: 300 }); ``` **Source**: []() ##### setSkipTaskbar() ```ts setSkipTaskbar(skip): Promise ``` Whether the window icon should be hidden from the taskbar or not. Platform-specific * **macOS:** Unsupported. ###### Parameters | Parameter | Type | Description | | --------- | --------- | ------------------------------------------- | | `skip` | `boolean` | true to hide window icon, false to show it. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setSkipTaskbar(true); ``` **Source**: []() ##### setTheme() ```ts setTheme(theme?): Promise ``` Set window theme, pass in `null` or `undefined` to follow system theme Platform-specific * **Linux / macOS**: Theme is app-wide and not specific to this window. * **iOS / Android:** Unsupported. ###### Parameters | Parameter | Type | | --------- | ----------------------------------------------------------------------- | | `theme`? | `null` \| [`Theme`](/reference/javascript/api/namespacewindow/#theme-2) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Since 2.0.0 **Source**: []() ##### setTitle() ```ts setTitle(title): Promise ``` Sets the window title. ###### Parameters | Parameter | Type | Description | | --------- | -------- | ------------- | | `title` | `string` | The new title | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().setTitle('Tauri'); ``` **Source**: []() ##### setTitleBarStyle() ```ts setTitleBarStyle(style): Promise ``` Sets the title bar style. **macOS only**. ###### Parameters | Parameter | Type | | --------- | ----------------------------------------------------------------------------- | | `style` | [`TitleBarStyle`](/reference/javascript/api/namespacewindow/#titlebarstyle-1) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Since 2.0.0 **Source**: []() ##### setVisibleOnAllWorkspaces() ```ts setVisibleOnAllWorkspaces(visible): Promise ``` Sets whether the window should be visible on all workspaces or virtual desktops. Platform-specific * **Windows / iOS / Android:** Unsupported. ###### Parameters | Parameter | Type | | --------- | --------- | | `visible` | `boolean` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Since 2.0.0 **Source**: []() ##### show() ```ts show(): Promise ``` Sets the window visibility to true. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().show(); ``` **Source**: []() ##### startDragging() ```ts startDragging(): Promise ``` Starts dragging the window. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().startDragging(); ``` **Source**: []() ##### startResizeDragging() ```ts startResizeDragging(direction): Promise ``` Starts resize-dragging the window. ###### Parameters | Parameter | Type | | ----------- | ----------------- | | `direction` | `ResizeDirection` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().startResizeDragging(); ``` **Source**: []() ##### theme() ```ts theme(): Promise ``` Gets the window’s current theme. Platform-specific * **macOS:** Theme was introduced on macOS 10.14. Returns `light` on macOS 10.13 and below. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`null` | [`Theme`](/reference/javascript/api/namespacewindow/#theme-2)> The window theme. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const theme = await getCurrentWindow().theme(); ``` **Source**: []() ##### title() ```ts title(): Promise ``` Gets the window’s current title. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; const title = await getCurrentWindow().title(); ``` **Source**: []() ##### toggleMaximize() ```ts toggleMaximize(): Promise ``` Toggles the window maximized state. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().toggleMaximize(); ``` **Source**: []() ##### unmaximize() ```ts unmaximize(): Promise ``` Unmaximizes the window. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().unmaximize(); ``` **Source**: []() ##### unminimize() ```ts unminimize(): Promise ``` Unminimizes the window. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. ###### Example ```typescript import { getCurrentWindow } from '@tauri-apps/api/window'; await getCurrentWindow().unminimize(); ``` **Source**: []() ##### getAll() ```ts static getAll(): Promise ``` Gets a list of instances of `Window` for all available windows. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Window`](/reference/javascript/api/namespacewindow/#window)\[]> **Source**: []() ##### getByLabel() ```ts static getByLabel(label): Promise ``` Gets the Window associated with the given label. ###### Parameters | Parameter | Type | Description | | --------- | -------- | ----------------- | | `label` | `string` | The window label. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`null` | [`Window`](/reference/javascript/api/namespacewindow/#window)> The Window instance to communicate with the window or null if the window doesn’t exist. ###### Example ```typescript import { Window } from '@tauri-apps/api/window'; const mainWindow = Window.getByLabel('main'); ``` **Source**: []() ##### getCurrent() ```ts static getCurrent(): Window ``` Get an instance of `Window` for the current window. ###### Returns [`Window`](/reference/javascript/api/namespacewindow/#window) **Source**: []() ##### getFocusedWindow() ```ts static getFocusedWindow(): Promise ``` Gets the focused window. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`null` | [`Window`](/reference/javascript/api/namespacewindow/#window)> The Window instance or `undefined` if there is not any focused window. ###### Example ```typescript import { Window } from '@tauri-apps/api/window'; const focusedWindow = Window.getFocusedWindow(); ``` **Source**: ## Interfaces []() ### Effects The window effects configuration object #### Since 2.0.0 #### Properties | Property | Type | Description | Defined in | | ------------- | ----------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | | []()`color?` | [`Color`](/reference/javascript/api/namespacewebview/#color) | Window effect color. Affects [Effect.Blur](/reference/javascript/api/namespacewindow/#blur) and [Effect.Acrylic](/reference/javascript/api/namespacewindow/#acrylic) only on Windows 10 v1903+. Doesn’t have any effect on Windows 7 or Windows 11. | **Source**: | | []()`effects` | [`Effect`](/reference/javascript/api/namespacewindow/#effect)\[] | List of Window effects to apply to the Window. Conflicting effects will apply the first one and ignore the rest. | **Source**: | | []()`radius?` | `number` | Window effect corner radius **macOS Only** | **Source**: | | []()`state?` | [`EffectState`](/reference/javascript/api/namespacewindow/#effectstate) | Window effect state **macOS Only** | **Source**: | *** []() ### Monitor Allows you to retrieve information about a given monitor. #### Since 1.0.0 #### Properties | Property | Type | Description | Defined in | | ----------------------- | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | []()`name` | `null` \| `string` | Human-readable name of the monitor | **Source**: | | []()`position` | [`PhysicalPosition`](/reference/javascript/api/namespacedpi/#physicalposition) | the Top-left corner position of the monitor relative to the larger full screen area, in physical pixels. Note that window creation options such as `x`, `y`, `width` and `height` expect logical pixels, so convert with [`Monitor.scaleFactor`](/reference/javascript/api/namespacewindow/#scalefactor-1) first: `import { currentMonitor } from '@tauri-apps/api/window'; import { WebviewWindow } from '@tauri-apps/api/webviewWindow'; const monitor = await currentMonitor(); if (monitor) { const position = monitor.position.toLogical(monitor.scaleFactor); const webview = new WebviewWindow('my-label', { x: position.x, y: position.y }); }` | **Source**: | | []()`scaleFactor` | `number` | The scale factor that can be used to map physical pixels to logical pixels, e.g. `monitor.position.toLogical(monitor.scaleFactor)`. | **Source**: | | []()`size` | [`PhysicalSize`](/reference/javascript/api/namespacedpi/#physicalsize) | The monitor’s resolution in physical pixels. Use [`Monitor.scaleFactor`](/reference/javascript/api/namespacewindow/#scalefactor-1) to convert to logical pixels: `const logicalSize = monitor.size.toLogical(monitor.scaleFactor);` | **Source**: | | []()`workArea` | `object` | The monitor’s work area (the monitor area excluding taskbars and docks) in physical pixels. Use [`Monitor.scaleFactor`](/reference/javascript/api/namespacewindow/#scalefactor-1) to convert to logical pixels as shown in [`Monitor.position`](/reference/javascript/api/namespacewindow/#position). | **Source**: | | []()`workArea.position` | [`PhysicalPosition`](/reference/javascript/api/namespacedpi/#physicalposition) | - | **Source**: | | []()`workArea.size` | [`PhysicalSize`](/reference/javascript/api/namespacedpi/#physicalsize) | - | **Source**: | *** []() ### ProgressBarState #### Properties | Property | Type | Description | Defined in | | --------------- | ----------------------------------------------------------------------------------- | ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | | []()`progress?` | `number` | The progress bar progress. This can be a value ranging from `0` to `100` | **Source**: | | []()`status?` | [`ProgressBarStatus`](/reference/javascript/api/namespacewindow/#progressbarstatus) | The progress bar status. | **Source**: | *** []() ### ScaleFactorChanged The payload for the `scaleChange` event. #### Since 1.0.2 #### Properties | Property | Type | Description | Defined in | | ----------------- | ---------------------------------------------------------------------- | ---------------------------- | ------------------------------------------------------------------------------------------ | | []()`scaleFactor` | `number` | The new window scale factor. | **Source**: | | []()`size` | [`PhysicalSize`](/reference/javascript/api/namespacedpi/#physicalsize) | The new window size | **Source**: | *** []() ### WindowOptions Configuration for the window to create. #### Since 1.0.0 #### Properties | Property | Type | Description | Defined in | | --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | | []()`activityName?` | `string` | The name of the Android activity to create for this window. | **Source**: | | []()`allowLinkPreview?` | `boolean` | on macOS and iOS there is a link preview on long pressing links, this is enabled by default. see | **Source**: | | []()`alwaysOnBottom?` | `boolean` | Whether the window should always be below other windows. | **Source**: | | []()`alwaysOnTop?` | `boolean` | Whether the window should always be on top of other windows or not. | **Source**: | | []()`backgroundColor?` | [`Color`](/reference/javascript/api/namespacewebview/#color) | Set the window background color. Platform-specific: - **Android / iOS:** Unsupported. - **Windows**: alpha channel is ignored. **Since** 2.1.0 | **Source**: | | []()`backgroundThrottling?` | [`BackgroundThrottlingPolicy`](/reference/javascript/api/namespacewindow/#backgroundthrottlingpolicy) | Change the default background throttling behaviour. ## Platform-specific - **Linux / Windows / Android**: Unsupported. Workarounds like a pending WebLock transaction might suffice. - **iOS**: Supported since version 17.0+. - **macOS**: Supported since version 14.0+. see **Since** 2.3.0 | **Source**: | | []()`center?` | `boolean` | Show window in the center of the screen.. | **Source**: | | []()`closable?` | `boolean` | Whether the window’s native close button is enabled or not. Defaults to `true`. | **Source**: | | []()`contentProtected?` | `boolean` | Prevents the window contents from being captured by other apps. | **Source**: | | []()`createdByActivityName?` | `string` | The name of the Android activity that is creating this webview window. This is important to determine which stack the activity will belong to. | **Source**: | | []()`decorations?` | `boolean` | Whether the window should have borders and bars or not. | **Source**: | | []()`disableInputAccessoryView?` | `boolean` | Allows disabling the input accessory view on iOS. The accessory view is the view that appears above the keyboard when a text input element is focused. It usually displays a view with “Done”, “Next” buttons. | **Source**: | | []()`focus?` | `boolean` | Whether the window will be initially focused or not. | **Source**: | | []()`focusable?` | `boolean` | Whether the window can be focused or not. | **Source**: | | []()`fullscreen?` | `boolean` | Whether the window is in fullscreen mode or not. | **Source**: | | []()`height?` | `number` | The initial height in logical pixels. | **Source**: | | []()`hiddenTitle?` | `boolean` | If `true`, sets the window title to be hidden on macOS. | **Source**: | | []()`javascriptDisabled?` | `boolean` | Whether we should disable JavaScript code execution on the webview or not. | **Source**: | | []()`maxHeight?` | `number` | The maximum height in logical pixels. Only applies if `maxWidth` is also set. | **Source**: | | []()`maxWidth?` | `number` | The maximum width in logical pixels. Only applies if `maxHeight` is also set. | **Source**: | | []()`maximizable?` | `boolean` | Whether the window’s native maximize button is enabled or not. Defaults to `true`. | **Source**: | | []()`maximized?` | `boolean` | Whether the window should be maximized upon creation or not. | **Source**: | | []()`minHeight?` | `number` | The minimum height in logical pixels. Only applies if `minWidth` is also set. | **Source**: | | []()`minWidth?` | `number` | The minimum width in logical pixels. Only applies if `minHeight` is also set. | **Source**: | | []()`minimizable?` | `boolean` | Whether the window’s native minimize button is enabled or not. Defaults to `true`. | **Source**: | | []()`noRedirectionBitmap?` | `boolean` | This sets `WS_EX_NOREDIRECTIONBITMAP`. This can avoid the white flash that may appear before the webview content is rendered when using a transparent window. **Windows only**. | **Source**: | | []()`parent?` | `string` \| [`Window`](/reference/javascript/api/namespacewindow/#window) \| [`WebviewWindow`](/reference/javascript/api/namespacewebviewwindow/#webviewwindow) | Sets a parent to the window to be created. Can be either a [`Window`](/reference/javascript/api/namespacewindow/#window) or a label of the window. Platform-specific - **Windows**: This sets the passed parent as an owner window to the window to be created. From [MSDN owned windows docs](https://docs.microsoft.com/en-us/windows/win32/winmsg/window-features#owned-windows): - An owned window is always above its owner in the z-order. - The system automatically destroys an owned window when its owner is destroyed. - An owned window is hidden when its owner is minimized. - **Linux**: This makes the new window transient for parent, see - **macOS**: This adds the window as a child of parent, see | **Source**: | | []()`preventOverflow?` | `boolean` \| `PreventOverflowMargin` | Prevent the window from overflowing the working area (e.g. monitor size - taskbar size) on creation, which means the window size will be limited to `monitor size - taskbar size` Can either be set to `true` or to a PreventOverflowMargin object to set an additional margin that should be considered to determine the working area (in this case the window size will be limited to `monitor size - taskbar size - margin`) **NOTE**: The overflow check is only performed on window creation, resizes can still overflow Platform-specific - **iOS / Android:** Unsupported. | **Source**: | | []()`requestedBySceneIdentifier?` | `string` | Sets the identifier of the UIScene that is requesting the creation of this new scene, establishing a relationship between the two scenes. By default the system uses the foreground scene. | **Source**: | | []()`resizable?` | `boolean` | Whether the window is resizable or not. | **Source**: | | []()`scrollBarStyle?` | [`ScrollBarStyle`](/reference/javascript/api/namespacewindow/#scrollbarstyle) | Specifies the native scrollbar style to use with the webview. CSS styles that modify the scrollbar are applied on top of the native appearance configured here. Defaults to `default`, which is the browser default. ## Platform-specific - **Windows**: - `fluentOverlay` requires WebView2 Runtime version 125.0.2535.41 or higher, and does nothing on older versions. - This option must be given the same value for all webviews. - **Linux / Android / iOS / macOS**: Unsupported. Only supports `Default` and performs no operation. | **Source**: | | []()`shadow?` | `boolean` | Whether or not the window has shadow. Platform-specific - **Windows:** - `false` has no effect on decorated window, shadows are always ON. - `true` will make undecorated window have a 1px white border, and on Windows 11, it will have a rounded corners. - **Linux:** Unsupported. **Since** 2.0.0 | **Source**: | | []()`skipTaskbar?` | `boolean` | Whether or not the window icon should be added to the taskbar. | **Source**: | | []()`tabbingIdentifier?` | `string` | Defines the window [tabbing identifier](https://developer.apple.com/documentation/appkit/nswindow/1644704-tabbingidentifier) on macOS. Windows with the same tabbing identifier will be grouped together. If the tabbing identifier is not set, automatic tabbing will be disabled. | **Source**: | | []()`theme?` | [`Theme`](/reference/javascript/api/namespacewindow/#theme-2) | The initial window theme. Defaults to the system theme. Only implemented on Windows and macOS 10.14+. | **Source**: | | []()`title?` | `string` | Window title. | **Source**: | | []()`titleBarStyle?` | [`TitleBarStyle`](/reference/javascript/api/namespacewindow/#titlebarstyle-1) | The style of the macOS title bar. | **Source**: | | []()`trafficLightPosition?` | [`LogicalPosition`](/reference/javascript/api/namespacedpi/#logicalposition) | The position of the window controls on macOS. Requires `titleBarStyle: 'overlay'` and `decorations: true`. **Since** 2.4.0 | **Source**: | | []()`transparent?` | `boolean` | Whether the window is transparent or not. Note that on `macOS` this requires the `macos-private-api` feature flag, enabled under `tauri.conf.json > app > macOSPrivateApi`. WARNING: Using private APIs on `macOS` prevents your application from being accepted to the `App Store`. On Windows, using `noRedirectionBitmap` can help avoid a white flash when creating a transparent window. | **Source**: | | []()`visible?` | `boolean` | Whether the window should be immediately visible upon creation or not. | **Source**: | | []()`visibleOnAllWorkspaces?` | `boolean` | Whether the window should be visible on all workspaces or virtual desktops. Platform-specific - **Windows / iOS / Android:** Unsupported. **Since** 2.0.0 | **Source**: | | []()`width?` | `number` | The initial width in logical pixels. | **Source**: | | []()`windowEffects?` | [`Effects`](/reference/javascript/api/namespacewindow/#effects) | Window effects. Requires the window to be transparent. Platform-specific: - **Windows**: If using decorations or shadows, you may want to try this workaround - **Linux**: Unsupported | **Source**: | | []()`x?` | `number` | The initial vertical position in logical pixels. Only applies if `y` is also set. | **Source**: | | []()`y?` | `number` | The initial horizontal position in logical pixels. Only applies if `x` is also set. | **Source**: | *** []() ### WindowSizeConstraints #### Properties | Property | Type | Defined in | | ---------------- | -------- | ------------------------------------------------------------------------------------------ | | []()`maxHeight?` | `number` | **Source**: | | []()`maxWidth?` | `number` | **Source**: | | []()`minHeight?` | `number` | **Source**: | | []()`minWidth?` | `number` | **Source**: | ## Type Aliases []() ### CursorIcon ```ts type CursorIcon: | "default" | "crosshair" | "hand" | "arrow" | "move" | "text" | "wait" | "help" | "progress" | "notAllowed" | "contextMenu" | "cell" | "verticalText" | "alias" | "copy" | "noDrop" | "grab" | "grabbing" | "allScroll" | "zoomIn" | "zoomOut" | "eResize" | "nResize" | "neResize" | "nwResize" | "sResize" | "seResize" | "swResize" | "wResize" | "ewResize" | "nsResize" | "neswResize" | "nwseResize" | "colResize" | "rowResize"; ``` **Source**: *** []() ### Theme ```ts type Theme: "light" | "dark"; ``` **Source**: *** []() ### TitleBarStyle ```ts type TitleBarStyle: "visible" | "transparent" | "overlay"; ``` **Source**: ## Functions []() ### availableMonitors() ```ts function availableMonitors(): Promise ``` Returns the list of all the monitors available on the system. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Monitor`](/reference/javascript/api/namespacewindow/#monitor)\[]> #### Example ```typescript import { availableMonitors } from '@tauri-apps/api/window'; const monitors = await availableMonitors(); ``` #### Since 1.0.0 **Source**: *** []() ### currentMonitor() ```ts function currentMonitor(): Promise ``` Returns the monitor on which the window currently resides. Returns `null` if current monitor can’t be detected. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Monitor`](/reference/javascript/api/namespacewindow/#monitor) | `null`> #### Example ```typescript import { currentMonitor } from '@tauri-apps/api/window'; const monitor = await currentMonitor(); ``` #### Since 1.0.0 **Source**: *** []() ### cursorPosition() ```ts function cursorPosition(): Promise ``` Get the cursor position relative to the top-left hand corner of the desktop. Note that the top-left hand corner of the desktop is not necessarily the same as the screen. If the user uses a desktop with multiple monitors, the top-left hand corner of the desktop is the top-left hand corner of the main monitor on Windows and macOS or the top-left of the leftmost monitor on X11. The coordinates can be negative if the top-left hand corner of the window is outside of the visible screen region. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`PhysicalPosition`](/reference/javascript/api/namespacedpi/#physicalposition)> **Source**: *** []() ### getAllWindows() ```ts function getAllWindows(): Promise ``` Gets a list of instances of `Window` for all available windows. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Window`](/reference/javascript/api/namespacewindow/#window)\[]> #### Since 1.0.0 **Source**: *** []() ### getCurrentWindow() ```ts function getCurrentWindow(): Window ``` Get an instance of `Window` for the current window. #### Returns [`Window`](/reference/javascript/api/namespacewindow/#window) #### Since 1.0.0 **Source**: *** []() ### monitorFromPoint() ```ts function monitorFromPoint(x, y): Promise ``` Returns the monitor that contains the given point. Returns `null` if can’t find any. #### Parameters | Parameter | Type | | --------- | -------- | | `x` | `number` | | `y` | `number` | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Monitor`](/reference/javascript/api/namespacewindow/#monitor) | `null`> #### Example ```typescript import { monitorFromPoint } from '@tauri-apps/api/window'; const monitor = await monitorFromPoint(100.0, 200.0); ``` #### Since 1.0.0 **Source**: *** []() ### primaryMonitor() ```ts function primaryMonitor(): Promise ``` Returns the primary monitor of the system. Returns `null` if it can’t identify any monitor as a primary one. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Monitor`](/reference/javascript/api/namespacewindow/#monitor) | `null`> #### Example ```typescript import { primaryMonitor } from '@tauri-apps/api/window'; const monitor = await primaryMonitor(); ``` #### Since 1.0.0 **Source**: # @tauri-apps/plugin-autostart ## Functions []() ### disable() ```ts function disable(): Promise ``` #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: *** []() ### enable() ```ts function enable(): Promise ``` #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: *** []() ### isEnabled() ```ts function isEnabled(): Promise ``` #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> **Source**: # @tauri-apps/plugin-barcode-scanner ## Enumerations []() ### Format #### Enumeration Members []() ##### Aztec ```ts Aztec: "AZTEC"; ``` **Source**: []() ##### Codabar ```ts Codabar: "CODABAR"; ``` Not supported on iOS. **Source**: []() ##### Code128 ```ts Code128: "CODE_128"; ``` **Source**: []() ##### Code39 ```ts Code39: "CODE_39"; ``` **Source**: []() ##### Code93 ```ts Code93: "CODE_93"; ``` **Source**: []() ##### DataMatrix ```ts DataMatrix: "DATA_MATRIX"; ``` **Source**: []() ##### EAN13 ```ts EAN13: "EAN_13"; ``` **Source**: []() ##### EAN8 ```ts EAN8: "EAN_8"; ``` **Source**: []() ##### GS1DataBar ```ts GS1DataBar: "GS1_DATA_BAR"; ``` Not supported on Android. Requires iOS 15.4+ **Source**: []() ##### GS1DataBarExpanded ```ts GS1DataBarExpanded: "GS1_DATA_BAR_EXPANDED"; ``` Not supported on Android. Requires iOS 15.4+ **Source**: []() ##### GS1DataBarLimited ```ts GS1DataBarLimited: "GS1_DATA_BAR_LIMITED"; ``` Not supported on Android. Requires iOS 15.4+ **Source**: []() ##### ITF ```ts ITF: "ITF"; ``` **Source**: []() ##### PDF417 ```ts PDF417: "PDF_417"; ``` **Source**: []() ##### QRCode ```ts QRCode: "QR_CODE"; ``` **Source**: []() ##### UPC\_A ```ts UPC_A: "UPC_A"; ``` Not supported on iOS. **Source**: []() ##### UPC\_E ```ts UPC_E: "UPC_E"; ``` **Source**: ## Interfaces []() ### ScanOptions #### Properties | Property | Type | Defined in | | ---------------------- | ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------- | | []()`cameraDirection?` | `"back"` \| `"front"` | **Source**: | | []()`formats?` | [`Format`](/reference/javascript/barcode-scanner/#format)\[] | **Source**: | | []()`windowed?` | `boolean` | **Source**: | *** []() ### Scanned #### Properties | Property | Type | Defined in | | ------------- | --------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | | []()`bounds` | `unknown` | **Source**: | | []()`content` | `string` | **Source**: | | []()`format` | [`Format`](/reference/javascript/barcode-scanner/#format) | **Source**: | ## Type Aliases []() ### PermissionState ```ts type PermissionState: "granted" | "denied" | "prompt" | "prompt-with-rationale"; ``` **Source**: undefined ## Functions []() ### cancel() ```ts function cancel(): Promise ``` Cancel the current scan process. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: *** []() ### checkPermissions() ```ts function checkPermissions(): Promise ``` Get permission state. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`PermissionState`> **Source**: *** []() ### openAppSettings() ```ts function openAppSettings(): Promise ``` Open application settings. Useful if permission was denied and the user must manually enable it. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: *** []() ### requestPermissions() ```ts function requestPermissions(): Promise ``` Request permissions to use the camera. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`PermissionState`> **Source**: *** []() ### scan() ```ts function scan(options?): Promise ``` Start scanning. #### Parameters | Parameter | Type | Description | | ---------- | ------------------------------------------------------------------- | ----------- | | `options`? | [`ScanOptions`](/reference/javascript/barcode-scanner/#scanoptions) | | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Scanned`](/reference/javascript/barcode-scanner/#scanned)> **Source**: # @tauri-apps/plugin-biometric ## Enumerations []() ### BiometryType #### Enumeration Members []() ##### FaceID ```ts FaceID: 2; ``` **Source**: []() ##### Iris ```ts Iris: 3; ``` **Source**: []() ##### None ```ts None: 0; ``` **Source**: []() ##### TouchID ```ts TouchID: 1; ``` **Source**: ## Interfaces []() ### AuthOptions #### Properties | Property | Type | Defined in | | ---------------------------- | --------- | ------------------------------------------------------------------------------------------------------------- | | []()`allowDeviceCredential?` | `boolean` | **Source**: | | []()`cancelTitle?` | `string` | **Source**: | | []()`confirmationRequired?` | `boolean` | **Source**: | | []()`fallbackTitle?` | `string` | **Source**: | | []()`maxAttemps?` | `number` | **Source**: | | []()`subtitle?` | `string` | **Source**: | | []()`title?` | `string` | **Source**: | *** []() ### Status #### Properties | Property | Type | Defined in | | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------- | | []()`biometryType` | [`BiometryType`](/reference/javascript/biometric/#biometrytype) | **Source**: | | []()`error?` | `string` | **Source**: | | []()`errorCode?` | \| `"appCancel"` \| `"authenticationFailed"` \| `"invalidContext"` \| `"notInteractive"` \| `"passcodeNotSet"` \| `"systemCancel"` \| `"userCancel"` \| `"userFallback"` \| `"biometryLockout"` \| `"biometryNotAvailable"` \| `"biometryNotEnrolled"` | **Source**: | | []()`isAvailable` | `boolean` | **Source**: | ## Functions []() ### authenticate() ```ts function authenticate(reason, options?): Promise ``` Prompts the user for authentication using the system interface (touchID, faceID or Android Iris). Rejects if the authentication fails. ```javascript import { authenticate } from "@tauri-apps/plugin-biometric"; await authenticate('Open your wallet'); ``` #### Parameters | Parameter | Type | Description | | ---------- | ------------------------------------------------------------- | ----------- | | `reason` | `string` | | | `options`? | [`AuthOptions`](/reference/javascript/biometric/#authoptions) | | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: *** []() ### checkStatus() ```ts function checkStatus(): Promise ``` Checks if the biometric authentication is available. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Status`](/reference/javascript/biometric/#status)> a promise resolving to an object containing all the information about the status of the biometry. **Source**: # @tauri-apps/plugin-cli Parse arguments from your Command Line Interface. ## Interfaces []() ### ArgMatch #### Since 2.0.0 #### Properties | Property | Type | Description | Defined in | | ----------------- | ---------------------------------------------- | -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | | []()`occurrences` | `number` | Number of occurrences | **Source**: | | []()`value` | `null` \| `string` \| `boolean` \| `string`\[] | string if takes value boolean if flag string\[] or null if takes multiple values | **Source**: | *** []() ### CliMatches #### Since 2.0.0 #### Properties | Property | Type | Defined in | | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | | []()`args` | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)<`string`, [`ArgMatch`](/reference/javascript/cli/#argmatch)> | **Source**: | | []()`subcommand` | `null` \| [`SubcommandMatch`](/reference/javascript/cli/#subcommandmatch) | **Source**: | *** []() ### SubcommandMatch #### Since 2.0.0 #### Properties | Property | Type | Defined in | | ------------- | ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | | []()`matches` | [`CliMatches`](/reference/javascript/cli/#climatches) | **Source**: | | []()`name` | `string` | **Source**: | ## Functions []() ### getMatches() ```ts function getMatches(): Promise ``` Parse the arguments provided to the current process and get the matches using the configuration defined [`tauri.cli`](https://tauri.app/v1/api/config/#tauriconfig.cli) in `tauri.conf.json` #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`CliMatches`](/reference/javascript/cli/#climatches)> #### Example ```typescript import { getMatches } from '@tauri-apps/plugin-cli'; const matches = await getMatches(); if (matches.subcommand?.name === 'run') { // `./your-app run $ARGS` was executed const args = matches.subcommand?.matches.args if ('debug' in args) { // `./your-app run --debug` was executed } } else { const args = matches.args // `./your-app $ARGS` was executed } ``` #### Since 2.0.0 **Source**: # @tauri-apps/plugin-clipboard-manager Read and write to the system clipboard. ## Functions []() ### clear() ```ts function clear(): Promise ``` Clears the clipboard. Platform-specific * **Android:** Only supported on SDK 28+. For older releases we write an empty string to the clipboard instead. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> #### Example ```typescript import { clear } from '@tauri-apps/plugin-clipboard-manager'; await clear(); ``` #### Since 2.0.0 **Source**: *** []() ### readImage() ```ts function readImage(): Promise ``` Gets the clipboard content as Uint8Array image. Platform-specific * **Android / iOS:** Not supported. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`Image`> #### Example ```typescript import { readImage } from '@tauri-apps/plugin-clipboard-manager'; const clipboardImage = await readImage(); const blob = new Blob([await clipboardImage.rgba()], { type: 'image' }) const url = URL.createObjectURL(blob) ``` #### Since 2.0.0 **Source**: *** []() ### readText() ```ts function readText(): Promise ``` Gets the clipboard content as plain text. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> #### Example ```typescript import { readText } from '@tauri-apps/plugin-clipboard-manager'; const clipboardText = await readText(); ``` #### Since 2.0.0 **Source**: *** []() ### writeHtml() ```ts function writeHtml(html, altText?): Promise ``` * Writes HTML or fallbacks to write provided plain text to the clipboard. Platform-specific * **Android / iOS:** Not supported. #### Parameters | Parameter | Type | | ---------- | -------- | | `html` | `string` | | `altText`? | `string` | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. #### Example ```typescript import { writeHtml } from '@tauri-apps/plugin-clipboard-manager'; await writeHtml('

Tauri is awesome!

', 'plaintext'); // The following will write "

Tauri is awesome

" as plain text await writeHtml('

Tauri is awesome!

', '

Tauri is awesome

'); // we can read html data only as a string so there's just readText(), no readHtml() assert(await readText(), '

Tauri is awesome!

'); ``` #### Since 2.0.0 **Source**: *** []() ### writeImage() ```ts function writeImage(image): Promise ``` Writes image buffer to the clipboard. Platform-specific * **Android / iOS:** Not supported. #### Parameters | Parameter | Type | | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `image` | \| `string` \| `number`\[] \| [`ArrayBuffer`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) \| [`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) \| `Image` | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. #### Example ```typescript import { writeImage } from '@tauri-apps/plugin-clipboard-manager'; const buffer = [ // A red pixel 255, 0, 0, 255, // A green pixel 0, 255, 0, 255, ]; await writeImage(buffer); ``` #### Since 2.0.0 **Source**: *** []() ### writeText() ```ts function writeText(text, opts?): Promise ``` Writes plain text to the clipboard. #### Parameters | Parameter | Type | | ------------- | -------- | | `text` | `string` | | `opts`? | `object` | | `opts.label`? | `string` | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. #### Example ```typescript import { writeText, readText } from '@tauri-apps/plugin-clipboard-manager'; await writeText('Tauri is awesome!'); assert(await readText(), 'Tauri is awesome!'); ``` #### Since 2.0.0 **Source**: # @tauri-apps/plugin-deep-link ## Functions []() ### getCurrent() ```ts function getCurrent(): Promise ``` Get the current URLs that triggered the deep link. Use this on app load to check whether your app was started via a deep link. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`\[] | `null`> #### Example ```typescript import { getCurrent } from '@tauri-apps/plugin-deep-link'; const urls = await getCurrent(); ``` Platform-specific * **Windows / Linux:** This function reads the command line arguments and checks if there’s only one value, which must be an URL with scheme matching one of the configured values. Note that you must manually check the arguments when registering deep link schemes dynamically with \[`Self::register`]. Additionally, the deep link might have been provided as a CLI argument so you should check if its format matches what you expect. #### Since 2.0.0 **Source**: *** []() ### isRegistered() ```ts function isRegistered(protocol): Promise ``` Check whether the app is the default handler for the specified protocol. #### Parameters | Parameter | Type | Description | | ---------- | -------- | --------------------------------------- | | `protocol` | `string` | The name of the protocol without `://`. | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> #### Example ```typescript import { isRegistered } from '@tauri-apps/plugin-deep-link'; await isRegistered("my-scheme"); ``` Platform-specific * **macOS / Android / iOS:** Unsupported. #### Since 2.0.0 **Source**: *** []() ### onOpenUrl() ```ts function onOpenUrl(handler): Promise ``` Helper function for the `deep-link://new-url` event to run a function each time the protocol is triggered while the app is running. Use `getCurrent` on app load to check whether your app was started via a deep link. #### Parameters | Parameter | Type | | --------- | ------------------ | | `handler` | (`urls`) => `void` | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`UnlistenFn`> #### Example ```typescript import { onOpenUrl } from '@tauri-apps/plugin-deep-link'; await onOpenUrl((urls) => { console.log(urls) }); ``` Platform-specific * **Windows / Linux:** Unsupported without the single-instance plugin. The OS will spawn a new app instance passing the URL as a CLI argument. #### Since 2.0.0 **Source**: *** []() ### register() ```ts function register(protocol): Promise ``` Register the app as the default handler for the specified protocol. #### Parameters | Parameter | Type | Description | | ---------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | | `protocol` | `string` | The name of the protocol without `://`. For example, if you want your app to handle `tauri://` links, call this method with `tauri` as the protocol. | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`null`> #### Example ```typescript import { register } from '@tauri-apps/plugin-deep-link'; await register("my-scheme"); ``` Platform-specific * **macOS / Android / iOS:** Unsupported. #### Since 2.0.0 **Source**: *** []() ### unregister() ```ts function unregister(protocol): Promise ``` Unregister the app as the default handler for the specified protocol. #### Parameters | Parameter | Type | Description | | ---------- | -------- | --------------------------------------- | | `protocol` | `string` | The name of the protocol without `://`. | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`null`> #### Example ```typescript import { unregister } from '@tauri-apps/plugin-deep-link'; await unregister("my-scheme"); ``` Platform-specific * **macOS / Linux / Android / iOS:** Unsupported. #### Since 2.0.0 **Source**: # @tauri-apps/plugin-dialog ## Interfaces []() ### ConfirmDialogOptions #### Properties | Property | Type | Description | Defined in | | ------------------ | ------------------------------------ | -------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | | []()`cancelLabel?` | `string` | The label of the cancel button. | **Source**: | | []()`kind?` | `"info"` \| `"warning"` \| `"error"` | The kind of the dialog. Defaults to `info`. | **Source**: | | []()`okLabel?` | `string` | The label of the confirm button. | **Source**: | | []()`title?` | `string` | The title of the dialog. Defaults to the app name. | **Source**: | *** []() ### DialogFilter Extension filters for the file dialog. #### Since 2.0.0 #### Properties | Property | Type | Description | Defined in | | ---------------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | | []()`extensions` | `string`\[] | Extensions to filter, without a `.` prefix. **Note:** Mobile platforms have different APIs for filtering that may not support extensions. iOS: Extensions are supported in the document picker, but not in the media picker. Android: Extensions are not supported. For these platforms, MIME types are the primary way to filter files, as opposed to extensions. This means the string values here labeled as `extensions` may also be a MIME type. This property name of `extensions` is being kept for backwards compatibility, but this may be revisited to specify the difference between extension or MIME type filtering. **Example** `extensions: ['svg', 'png']` | **Source**: | | []()`name` | `string` | Filter name. | **Source**: | *** []() ### MessageDialogOptions #### Since 2.0.0 #### Properties | Property | Type | Description | Defined in | | ------------------ | ---------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | | []()`buttons?` | [`MessageDialogButtons`](/reference/javascript/dialog/#messagedialogbuttons) | The buttons of the dialog. **Example** `// Use system default buttons texts await message('Hello World!', { buttons: 'Ok' }) await message('Hello World!', { buttons: 'OkCancel' }) // Or with custom button texts await message('Hello World!', { buttons: { ok: 'Yes!' } }) await message('Take on the task?', { buttons: { ok: 'Accept', cancel: 'Cancel' } }) await message('Show the file content?', { buttons: { yes: 'Show content', no: 'Show in folder', cancel: 'Cancel' } })` **Since** 2.4.0 | **Source**: | | []()`kind?` | `"info"` \| `"warning"` \| `"error"` | The kind of the dialog. Defaults to `info`. | **Source**: | | []()~~`okLabel?`~~ | `string` | The label of the Ok button. **Deprecated** Use [`MessageDialogOptions.buttons`](/reference/javascript/dialog/#buttons) instead. | **Source**: | | []()`title?` | `string` | The title of the dialog. Defaults to the app name. | **Source**: | *** []() ### OpenDialogOptions Options for the open dialog. #### Since 2.0.0 #### Properties | Property | Type | Description | Defined in | | --------------------------- | ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------- | | []()`canCreateDirectories?` | `boolean` | Whether to allow creating directories in the dialog. Enabled by default. **macOS Only** | **Source**: | | []()`defaultPath?` | `string` | Initial directory or file path. If it’s a directory path, the dialog interface will change to that folder. If it’s not an existing directory, the file name will be set to the dialog’s file name input and the dialog will be set to the parent folder. On mobile the file name is always used on the dialog’s file name input. If not provided, Android uses `(invalid).txt` as default file name. | **Source**: | | []()`directory?` | `boolean` | Whether the dialog is a directory selection or not. | **Source**: | | []()`fileAccessMode?` | [`FileAccessMode`](/reference/javascript/dialog/#fileaccessmode-1) | The file access mode of the dialog. If not provided, `copy` is used, which matches the behavior of the [`open`](/reference/javascript/dialog/#open) method before the introduction of this option. **Usage** If a file is opened with [`: 'copy'`](/reference/javascript/dialog/#fileaccessmode), it will be copied to the app’s sandbox. This means the file can be read, edited, deleted, copied, or any other operation without any issues, since the file now belongs to the app. This also means that the caller has responsibility of deleting the file if this file is not meant to be retained in the app sandbox. If a file is opened with [`: 'scoped'`](/reference/javascript/dialog/#fileaccessmode), the file will remain in its original location and security-scoped access will be automatically managed by the system. **Note** This is specifically meant for document pickers on iOS or MacOS, in conjunction with [security scoped resources](https://developer.apple.com/documentation/foundation/nsurl/startaccessingsecurityscopedresource\(\)). Why only document pickers, and not image or video pickers? The image and video pickers on iOS behave differently from the document pickers, and return [NSItemProvider](https://developer.apple.com/documentation/foundation/nsitemprovider) objects instead of file URLs. These are meant to be ephemeral (only available within the callback of the picker), and are not accessible outside of the callback. So for image and video pickers, the only way to access the file is to copy it to the app’s sandbox, and this is the URL that is returned from this API. This means there is no provision for using `scoped` mode with image or video pickers. If an image or video picker is used, `copy` is always used. | **Source**: | | []()`filters?` | [`DialogFilter`](/reference/javascript/dialog/#dialogfilter)\[] | The filters of the dialog. On mobile platforms, if either: A) the [`pickerMode`](/reference/javascript/dialog/#pickermode) is set to `media`, `image`, or `video` – or – B) the filters include **only** either image or video mime types, the media picker will be displayed. Otherwise, the document picker will be displayed. | **Source**: | | []()`multiple?` | `boolean` | Whether the dialog allows multiple selection or not. | **Source**: | | []()`pickerMode?` | [`PickerMode`](/reference/javascript/dialog/#pickermode-1) | The preferred mode of the dialog. This is meant for mobile platforms (iOS and Android) which have distinct file and media pickers. If not provided, the dialog will automatically choose the best mode based on the MIME types or extensions of the [`filters`](/reference/javascript/dialog/#filters). On desktop, this option is ignored. | **Source**: | | []()`recursive?` | `boolean` | If `directory` is true, indicates that it will be read recursively later. Defines whether subdirectories will be allowed on the scope or not. | **Source**: | | []()`title?` | `string` | The title of the dialog window (desktop only). | **Source**: | *** []() ### SaveDialogOptions Options for the save dialog. #### Since 2.0.0 #### Properties | Property | Type | Description | Defined in | | --------------------------- | --------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | | []()`canCreateDirectories?` | `boolean` | Whether to allow creating directories in the dialog. Enabled by default. **macOS Only** | **Source**: | | []()`defaultPath?` | `string` | Initial directory or file path. If it’s a directory path, the dialog interface will change to that folder. If it’s not an existing directory, the file name will be set to the dialog’s file name input and the dialog will be set to the parent folder. On mobile the file name is always used on the dialog’s file name input. If not provided, Android uses `(invalid).txt` as default file name. | **Source**: | | []()`filters?` | [`DialogFilter`](/reference/javascript/dialog/#dialogfilter)\[] | The filters of the dialog. | **Source**: | | []()`title?` | `string` | The title of the dialog window (desktop only). | **Source**: | ## Type Aliases []() ### FileAccessMode ```ts type FileAccessMode: "copy" | "scoped"; ``` The file access mode of the dialog. * `copy`: copy/move the picked file to the app sandbox; no scoped access required. * `scoped`: keep file in place; security-scoped access is automatically managed. **Note:** This option is only supported on iOS 14 and above. This parameter is ignored on iOS 13 and below. **Source**: *** []() ### MessageDialogButtons ```ts type MessageDialogButtons: MessageDialogDefaultButtons | MessageDialogCustomButtons; ``` The buttons of a message dialog. #### Since 2.4.0 **Source**: *** []() ### MessageDialogButtonsOk ```ts type MessageDialogButtonsOk: object & BanExcept<"ok">; ``` The Ok button of a message dialog. #### Type declaration | Name | Type | Description | Defined in | | ---- | -------- | -------------- | ----------------------------------------------------------------------------------------------------------- | | `ok` | `string` | The Ok button. | **Source**: | #### Since 2.4.0 **Source**: *** []() ### MessageDialogButtonsOkCancel ```ts type MessageDialogButtonsOkCancel: object & BanExcept<"ok" | "cancel">; ``` The Ok and Cancel buttons of a message dialog. #### Type declaration | Name | Type | Description | Defined in | | -------- | -------- | ------------------ | ----------------------------------------------------------------------------------------------------------- | | `cancel` | `string` | The Cancel button. | **Source**: | | `ok` | `string` | The Ok button. | **Source**: | #### Since 2.4.0 **Source**: *** []() ### MessageDialogButtonsYesNoCancel ```ts type MessageDialogButtonsYesNoCancel: object & BanExcept<"yes" | "no" | "cancel">; ``` The Yes, No and Cancel buttons of a message dialog. #### Type declaration | Name | Type | Description | Defined in | | -------- | -------- | ------------------ | ----------------------------------------------------------------------------------------------------------- | | `cancel` | `string` | The Cancel button. | **Source**: | | `no` | `string` | The No button. | **Source**: | | `yes` | `string` | The Yes button. | **Source**: | #### Since 2.4.0 **Source**: *** []() ### MessageDialogCustomButtons ```ts type MessageDialogCustomButtons: MessageDialogButtonsYesNoCancel | MessageDialogButtonsOkCancel | MessageDialogButtonsOk; ``` Custom buttons for a message dialog. #### Since 2.4.0 **Source**: *** []() ### MessageDialogDefaultButtons ```ts type MessageDialogDefaultButtons: "Ok" | "OkCancel" | "YesNo" | "YesNoCancel"; ``` Default buttons for a message dialog. #### Since 2.4.0 **Source**: *** []() ### MessageDialogResult ```ts type MessageDialogResult: | "Yes" | "No" | "Ok" | "Cancel" | string & object; ``` The result of a message dialog. The result is a string if the dialog has custom buttons, otherwise it is one of the default buttons. #### Since 2.4.0 **Source**: *** []() ### OpenDialogReturn\ ```ts type OpenDialogReturn: T["directory"] extends true ? T["multiple"] extends true ? string[] | null : string | null : T["multiple"] extends true ? string[] | null : string | null; ``` #### Type Parameters | Type Parameter | | ------------------------------------------------------------------------------------ | | `T` *extends* [`OpenDialogOptions`](/reference/javascript/dialog/#opendialogoptions) | **Source**: *** []() ### PickerMode ```ts type PickerMode: "document" | "media" | "image" | "video"; ``` The preferred mode of the dialog. This is meant for mobile platforms (iOS and Android) which have distinct file and media pickers. On desktop, this option is ignored. If not provided, the dialog will automatically choose the best mode based on the MIME types or extensions of the filters. **Note:** This option is only supported on iOS 14 and above. This parameter is ignored on iOS 13 and below. **Source**: ## Functions []() ### ask() ```ts function ask(message, options?): Promise ``` Shows a question dialog with `Yes` and `No` buttons. Convenient wrapper for `await message('msg', { buttons: 'YesNo' }) === 'Yes'` #### Parameters | Parameter | Type | Description | | ---------- | ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------ | | `message` | `string` | The message to show. | | `options`? | `string` \| [`ConfirmDialogOptions`](/reference/javascript/dialog/#confirmdialogoptions) | The dialog’s options. If a string, it represents the dialog title. | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> A promise resolving to a boolean indicating whether `Yes` was clicked or not. #### Example ```typescript import { ask } from '@tauri-apps/plugin-dialog'; const yes = await ask('Are you sure?', 'Tauri'); const yes2 = await ask('This action cannot be reverted. Are you sure?', { title: 'Tauri', kind: 'warning' }); ``` #### Since 2.0.0 **Source**: *** []() ### confirm() ```ts function confirm(message, options?): Promise ``` Shows a question dialog with `Ok` and `Cancel` buttons. Convenient wrapper for `await message('msg', { buttons: 'OkCancel' }) === 'Ok'` #### Parameters | Parameter | Type | Description | | ---------- | ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------ | | `message` | `string` | The message to show. | | `options`? | `string` \| [`ConfirmDialogOptions`](/reference/javascript/dialog/#confirmdialogoptions) | The dialog’s options. If a string, it represents the dialog title. | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> A promise resolving to a boolean indicating whether `Ok` was clicked or not. #### Example ```typescript import { confirm } from '@tauri-apps/plugin-dialog'; const confirmed = await confirm('Are you sure?', 'Tauri'); const confirmed2 = await confirm('This action cannot be reverted. Are you sure?', { title: 'Tauri', kind: 'warning' }); ``` #### Since 2.0.0 **Source**: *** []() ### message() ```ts function message(message, options?): Promise ``` Shows a message dialog with an `Ok` button. #### Parameters | Parameter | Type | Description | | ---------- | ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------ | | `message` | `string` | The message to show. | | `options`? | `string` \| [`MessageDialogOptions`](/reference/javascript/dialog/#messagedialogoptions) | The dialog’s options. If a string, it represents the dialog title. | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`MessageDialogResult`](/reference/javascript/dialog/#messagedialogresult)> A promise indicating the success or failure of the operation. #### Example ```typescript import { message } from '@tauri-apps/plugin-dialog'; await message('Tauri is awesome', 'Tauri'); await message('File not found', { title: 'Tauri', kind: 'error' }); ``` #### Since 2.0.0 **Source**: *** []() ### open() ```ts function open(options): Promise> ``` Open a file/directory selection dialog. The selected paths are added to the filesystem and asset protocol scopes. When security is more important than the easy of use of this API, prefer writing a dedicated command instead. Note that the scope change is not persisted, so the values are cleared when the application is restarted. You can save it to the filesystem using [tauri-plugin-persisted-scope](https://github.com/tauri-apps/tauri-plugin-persisted-scope). #### Type Parameters | Type Parameter | | ------------------------------------------------------------------------------------ | | `T` *extends* [`OpenDialogOptions`](/reference/javascript/dialog/#opendialogoptions) | #### Parameters | Parameter | Type | | --------- | ---- | | `options` | `T` | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`OpenDialogReturn`](/reference/javascript/dialog/#opendialogreturnt)<`T`>> A promise resolving to the selected path(s) #### Examples ```typescript import { open } from '@tauri-apps/plugin-dialog'; // Open a selection dialog for image files const selected = await open({ multiple: true, filters: [{ name: 'Image', extensions: ['png', 'jpeg'] }] }); if (Array.isArray(selected)) { // user selected multiple files } else if (selected === null) { // user cancelled the selection } else { // user selected a single file } ``` ```typescript import { open } from '@tauri-apps/plugin-dialog'; import { appDir } from '@tauri-apps/api/path'; // Open a selection dialog for directories const selected = await open({ directory: true, multiple: true, defaultPath: await appDir(), }); if (Array.isArray(selected)) { // user selected multiple directories } else if (selected === null) { // user cancelled the selection } else { // user selected a single directory } ``` #### Since 2.0.0 **Source**: *** []() ### save() ```ts function save(options): Promise ``` Open a file/directory save dialog. The selected path is added to the filesystem and asset protocol scopes. When security is more important than the easy of use of this API, prefer writing a dedicated command instead. Note that the scope change is not persisted, so the values are cleared when the application is restarted. You can save it to the filesystem using [tauri-plugin-persisted-scope](https://github.com/tauri-apps/tauri-plugin-persisted-scope). #### Parameters | Parameter | Type | | --------- | ---------------------------------------------------------------------- | | `options` | [`SaveDialogOptions`](/reference/javascript/dialog/#savedialogoptions) | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string` | `null`> A promise resolving to the selected path. #### Example ```typescript import { save } from '@tauri-apps/plugin-dialog'; const filePath = await save({ filters: [{ name: 'Image', extensions: ['png', 'jpeg'] }] }); ``` #### Since 2.0.0 **Source**: # @tauri-apps/plugin-fs Access the file system. ## iOS security-scoped resources On iOS, the `fs` plugin automatically manages access to security-scoped resources when a file URL is accessed. This is required for files outside the app’s sandbox (e.g., from file picker). ## Example ```typescript import { open } from '@tauri-apps/plugin-fs'; const file = await open('file:///path/to/file.txt'); await file.close(); ``` ## Security This module prevents path traversal, not allowing parent directory accessors to be used (i.e. “/usr/path/to/../file” or “../path/to/file” paths are not allowed). Paths accessed with this API must be either relative to one of the [base directories](/reference/javascript/fs/#basedirectory) or created with the [path API](https://v2.tauri.app/reference/javascript/api/namespacepath/). The API has a scope configuration that forces you to restrict the paths that can be accessed using glob patterns. The scope configuration is an array of glob patterns describing file/directory paths that are allowed. For instance, this scope configuration allows **all** enabled `fs` APIs to (only) access files in the *databases* directory of the [`$APPDATA` directory](https://v2.tauri.app/reference/javascript/api/namespacepath/#appdatadir): ```json { "permissions": [ { "identifier": "fs:scope", "allow": [{ "path": "$APPDATA/databases/*" }] } ] } ``` Scopes can also be applied to specific `fs` APIs by using the API’s identifier instead of `fs:scope`: ```json { "permissions": [ { "identifier": "fs:allow-exists", "allow": [{ "path": "$APPDATA/databases/*" }] } ] } ``` Notice the use of the `$APPDATA` variable. The value is injected at runtime, resolving to the [app data directory](https://v2.tauri.app/reference/javascript/api/namespacepath/#appdatadir). The available variables are: [`$APPCONFIG`](https://v2.tauri.app/reference/javascript/api/namespacepath/#appconfigdir), [`$APPDATA`](https://v2.tauri.app/reference/javascript/api/namespacepath/#appdatadir), [`$APPLOCALDATA`](https://v2.tauri.app/reference/javascript/api/namespacepath/#applocaldatadir), [`$APPCACHE`](https://v2.tauri.app/reference/javascript/api/namespacepath/#appcachedir), [`$APPLOG`](https://v2.tauri.app/reference/javascript/api/namespacepath/#applogdir), [`$AUDIO`](https://v2.tauri.app/reference/javascript/api/namespacepath/#audiodir), [`$CACHE`](https://v2.tauri.app/reference/javascript/api/namespacepath/#cachedir), [`$CONFIG`](https://v2.tauri.app/reference/javascript/api/namespacepath/#configdir), [`$DATA`](https://v2.tauri.app/reference/javascript/api/namespacepath/#datadir), [`$LOCALDATA`](https://v2.tauri.app/reference/javascript/api/namespacepath/#localdatadir), [`$DESKTOP`](https://v2.tauri.app/reference/javascript/api/namespacepath/#desktopdir), [`$DOCUMENT`](https://v2.tauri.app/reference/javascript/api/namespacepath/#documentdir), [`$DOWNLOAD`](https://v2.tauri.app/reference/javascript/api/namespacepath/#downloaddir), [`$EXE`](https://v2.tauri.app/reference/javascript/api/namespacepath/#executabledir), [`$FONT`](https://v2.tauri.app/reference/javascript/api/namespacepath/#fontdir), [`$HOME`](https://v2.tauri.app/reference/javascript/api/namespacepath/#homedir), [`$PICTURE`](https://v2.tauri.app/reference/javascript/api/namespacepath/#picturedir), [`$PUBLIC`](https://v2.tauri.app/reference/javascript/api/namespacepath/#publicdir), [`$RUNTIME`](https://v2.tauri.app/reference/javascript/api/namespacepath/#runtimedir), [`$TEMPLATE`](https://v2.tauri.app/reference/javascript/api/namespacepath/#templatedir), [`$VIDEO`](https://v2.tauri.app/reference/javascript/api/namespacepath/#videodir), [`$RESOURCE`](https://v2.tauri.app/reference/javascript/api/namespacepath/#resourcedir), [`$TEMP`](https://v2.tauri.app/reference/javascript/api/namespacepath/#tempdir). Trying to execute any API with a URL not configured on the scope results in a promise rejection due to denied access. ## Enumerations []() ### BaseDirectory #### Since 2.0.0 #### Enumeration Members []() ##### AppCache ```ts AppCache: 16; ``` ###### See appCacheDir for more information. **Source**: undefined []() ##### AppConfig ```ts AppConfig: 13; ``` ###### See appConfigDir for more information. **Source**: undefined []() ##### AppData ```ts AppData: 14; ``` ###### See appDataDir for more information. **Source**: undefined []() ##### AppLocalData ```ts AppLocalData: 15; ``` ###### See appLocalDataDir for more information. **Source**: undefined []() ##### AppLog ```ts AppLog: 17; ``` ###### See appLogDir for more information. **Source**: undefined []() ##### Audio ```ts Audio: 1; ``` ###### See audioDir for more information. **Source**: undefined []() ##### Cache ```ts Cache: 2; ``` ###### See cacheDir for more information. **Source**: undefined []() ##### Config ```ts Config: 3; ``` ###### See configDir for more information. **Source**: undefined []() ##### Data ```ts Data: 4; ``` ###### See dataDir for more information. **Source**: undefined []() ##### Desktop ```ts Desktop: 18; ``` ###### See desktopDir for more information. **Source**: undefined []() ##### Document ```ts Document: 6; ``` ###### See documentDir for more information. **Source**: undefined []() ##### Download ```ts Download: 7; ``` ###### See downloadDir for more information. **Source**: undefined []() ##### Executable ```ts Executable: 19; ``` ###### See executableDir for more information. **Source**: undefined []() ##### Font ```ts Font: 20; ``` ###### See fontDir for more information. **Source**: undefined []() ##### Home ```ts Home: 21; ``` ###### See homeDir for more information. **Source**: undefined []() ##### LocalData ```ts LocalData: 5; ``` ###### See localDataDir for more information. **Source**: undefined []() ##### Picture ```ts Picture: 8; ``` ###### See pictureDir for more information. **Source**: undefined []() ##### Public ```ts Public: 9; ``` ###### See publicDir for more information. **Source**: undefined []() ##### Resource ```ts Resource: 11; ``` ###### See resourceDir for more information. **Source**: undefined []() ##### Runtime ```ts Runtime: 22; ``` ###### See runtimeDir for more information. **Source**: undefined []() ##### Temp ```ts Temp: 12; ``` ###### See tempDir for more information. **Source**: undefined []() ##### Template ```ts Template: 23; ``` ###### See templateDir for more information. **Source**: undefined []() ##### Video ```ts Video: 10; ``` ###### See videoDir for more information. **Source**: undefined *** []() ### SeekMode #### Enumeration Members []() ##### Current ```ts Current: 1; ``` **Source**: []() ##### End ```ts End: 2; ``` **Source**: []() ##### Start ```ts Start: 0; ``` **Source**: ## Classes []() ### FileHandle The Tauri abstraction for reading and writing files. #### Since 2.0.0 #### Extends * `Resource` #### Constructors []() ##### new FileHandle() ```ts new FileHandle(rid): FileHandle ``` ###### Parameters | Parameter | Type | | --------- | -------- | | `rid` | `number` | ###### Returns [`FileHandle`](/reference/javascript/fs/#filehandle) ###### Inherited from `Resource.constructor` **Source**: undefined #### Accessors []() ##### rid ```ts get rid(): number ``` ###### Returns `number` ###### Inherited from `Resource.rid` **Source**: undefined #### Methods []() ##### close() ```ts close(): Promise ``` Destroys and cleans up this resource from memory. **You should not call any method on this object anymore and should drop any reference to it.** ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Inherited from `Resource.close` **Source**: undefined []() ##### read() ```ts read(buffer): Promise ``` Reads up to `p.byteLength` bytes into `p`. It resolves to the number of bytes read (`0` < `n` <= `p.byteLength`) and rejects if any error encountered. Even if `read()` resolves to `n` < `p.byteLength`, it may use all of `p` as scratch space during the call. If some data is available but not `p.byteLength` bytes, `read()` conventionally resolves to what is available instead of waiting for more. When `read()` encounters end-of-file condition, it resolves to EOF (`null`). When `read()` encounters an error, it rejects with an error. Callers should always process the `n` > `0` bytes returned before considering the EOF (`null`). Doing so correctly handles I/O errors that happen after reading some bytes and also both of the allowed EOF behaviors. ###### Parameters | Parameter | Type | | --------- | ----------------------------------------------------------------------------------------------------- | | `buffer` | [`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`null` | `number`> ###### Example ```typescript import { open, BaseDirectory } from "@tauri-apps/plugin-fs" // if "$APPCONFIG/foo/bar.txt" contains the text "hello world": const file = await open("foo/bar.txt", { baseDir: BaseDirectory.AppConfig }); const buf = new Uint8Array(100); const numberOfBytesRead = await file.read(buf); // 11 bytes const text = new TextDecoder().decode(buf); // "hello world" await file.close(); ``` ###### Since 2.0.0 **Source**: []() ##### seek() ```ts seek(offset, whence): Promise ``` Seek sets the offset for the next `read()` or `write()` to offset, interpreted according to `whence`: `Start` means relative to the start of the file, `Current` means relative to the current offset, and `End` means relative to the end. Seek resolves to the new offset relative to the start of the file. Seeking to an offset before the start of the file is an error. Seeking to any positive offset is legal, but the behavior of subsequent I/O operations on the underlying object is implementation-dependent. It returns the number of cursor position. ###### Parameters | Parameter | Type | | --------- | ------------------------------------------------ | | `offset` | `number` | | `whence` | [`SeekMode`](/reference/javascript/fs/#seekmode) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`number`> ###### Example ```typescript import { open, SeekMode, BaseDirectory } from '@tauri-apps/plugin-fs'; // Given hello.txt pointing to file with "Hello world", which is 11 bytes long: const file = await open('hello.txt', { read: true, write: true, truncate: true, create: true, baseDir: BaseDirectory.AppLocalData }); await file.write(new TextEncoder().encode("Hello world")); // Seek 6 bytes from the start of the file console.log(await file.seek(6, SeekMode.Start)); // "6" // Seek 2 more bytes from the current position console.log(await file.seek(2, SeekMode.Current)); // "8" // Seek backwards 2 bytes from the end of the file console.log(await file.seek(-2, SeekMode.End)); // "9" (e.g. 11-2) await file.close(); ``` ###### Since 2.0.0 **Source**: []() ##### stat() ```ts stat(): Promise ``` Returns a [`FileInfo`](/reference/javascript/fs/#fileinfo) for this file. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`FileInfo`](/reference/javascript/fs/#fileinfo)> ###### Example ```typescript import { open, BaseDirectory } from '@tauri-apps/plugin-fs'; const file = await open("file.txt", { read: true, baseDir: BaseDirectory.AppLocalData }); const fileInfo = await file.stat(); console.log(fileInfo.isFile); // true await file.close(); ``` ###### Since 2.0.0 **Source**: []() ##### truncate() ```ts truncate(len?): Promise ``` Truncates or extends this file, to reach the specified `len`. If `len` is not specified then the entire file contents are truncated. ###### Parameters | Parameter | Type | | --------- | -------- | | `len`? | `number` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Example ```typescript import { open, BaseDirectory } from '@tauri-apps/plugin-fs'; // truncate the entire file const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.AppLocalData }); await file.truncate(); // truncate part of the file const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.AppLocalData }); await file.write(new TextEncoder().encode("Hello World")); await file.truncate(7); const data = new Uint8Array(32); await file.read(data); console.log(new TextDecoder().decode(data)); // Hello W await file.close(); ``` ###### Since 2.0.0 **Source**: []() ##### write() ```ts write(data): Promise ``` Writes `data.byteLength` bytes from `data` to the underlying data stream. It resolves to the number of bytes written from `data` (`0` <= `n` <= `data.byteLength`) or reject with the error encountered that caused the write to stop early. `write()` must reject with a non-null error if would resolve to `n` < `data.byteLength`. `write()` must not modify the slice data, even temporarily. ###### Parameters | Parameter | Type | | --------- | ----------------------------------------------------------------------------------------------------- | | `data` | [`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`number`> ###### Example ```typescript import { open, write, BaseDirectory } from '@tauri-apps/plugin-fs'; const encoder = new TextEncoder(); const data = encoder.encode("Hello world"); const file = await open("bar.txt", { write: true, baseDir: BaseDirectory.AppLocalData }); const bytesWritten = await file.write(data); // 11 await file.close(); ``` ###### Since 2.0.0 **Source**: ## Interfaces []() ### CopyFileOptions #### Since 2.0.0 #### Properties | Property | Type | Description | Defined in | | ---------------------- | ---------------------------------------------------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------- | | []()`fromPathBaseDir?` | [`BaseDirectory`](/reference/javascript/fs/#basedirectory) | Base directory for `fromPath`. | **Source**: | | []()`toPathBaseDir?` | [`BaseDirectory`](/reference/javascript/fs/#basedirectory) | Base directory for `toPath`. | **Source**: | *** []() ### CreateOptions #### Since 2.0.0 #### Properties | Property | Type | Description | Defined in | | -------------- | ---------------------------------------------------------- | ------------------------- | ------------------------------------------------------------------------------------------------------- | | []()`baseDir?` | [`BaseDirectory`](/reference/javascript/fs/#basedirectory) | Base directory for `path` | **Source**: | *** []() ### DebouncedWatchOptions #### Since 2.0.0 #### Extends * [`WatchOptions`](/reference/javascript/fs/#watchoptions) #### Properties | Property | Type | Description | Inherited from | Defined in | | ---------------- | ---------------------------------------------------------- | ----------------------------- | ------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | | []()`baseDir?` | [`BaseDirectory`](/reference/javascript/fs/#basedirectory) | Base directory for `path` | [`WatchOptions`](/reference/javascript/fs/#watchoptions).[`baseDir`](/reference/javascript/fs/#basedir-10) | **Source**: | | []()`delayMs?` | `number` | Debounce delay | - | **Source**: | | []()`recursive?` | `boolean` | Watch a directory recursively | [`WatchOptions`](/reference/javascript/fs/#watchoptions).[`recursive`](/reference/javascript/fs/#recursive-3) | **Source**: | *** []() ### DirEntry A disk entry which is either a file, a directory or a symlink. This is the result of the [`readDir`](/reference/javascript/fs/#readdir). #### Since 2.0.0 #### Properties | Property | Type | Description | Defined in | | ----------------- | --------- | ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | | []()`isDirectory` | `boolean` | Specifies whether this entry is a directory or not. | **Source**: | | []()`isFile` | `boolean` | Specifies whether this entry is a file or not. | **Source**: | | []()`isSymlink` | `boolean` | Specifies whether this entry is a symlink or not. | **Source**: | | []()`name` | `string` | The name of the entry (file name with extension or directory name). | **Source**: | *** []() ### ExistsOptions #### Since 2.0.0 #### Properties | Property | Type | Description | Defined in | | -------------- | ---------------------------------------------------------- | -------------------------- | -------------------------------------------------------------------------------------------------------- | | []()`baseDir?` | [`BaseDirectory`](/reference/javascript/fs/#basedirectory) | Base directory for `path`. | **Source**: | *** []() ### FileInfo A FileInfo describes a file and is returned by `stat`, `lstat` or `fstat`. #### Since 2.0.0 #### Properties | Property | Type | Description | Defined in | | -------------------- | --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | | []()`atime` | `null` \| [`Date`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date) | The last access time of the file. This corresponds to the `atime` field from `stat` on Unix and `ftLastAccessTime` on Windows. This may not be available on all platforms. | **Source**: | | []()`birthtime` | `null` \| [`Date`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date) | The creation time of the file. This corresponds to the `birthtime` field from `stat` on Mac/BSD and `ftCreationTime` on Windows. This may not be available on all platforms. | **Source**: | | []()`blksize` | `null` \| `number` | Blocksize for filesystem I/O. Platform-specific - **Windows:** Unsupported. | **Source**: | | []()`blocks` | `null` \| `number` | Number of blocks allocated to the file, in 512-byte units. Platform-specific - **Windows:** Unsupported. | **Source**: | | []()`dev` | `null` \| `number` | ID of the device containing the file. Platform-specific - **Windows:** Unsupported. | **Source**: | | []()`fileAttributes` | `null` \| `number` | This field contains the file system attribute information for a file or directory. For possible values and their descriptions, see [File Attribute Constants](https://docs.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants) in the Windows Dev Center Platform-specific - **macOS / Linux / Android / iOS:** Unsupported. | **Source**: | | []()`gid` | `null` \| `number` | Group ID of the owner of this file. Platform-specific - **Windows:** Unsupported. | **Source**: | | []()`ino` | `null` \| `number` | Inode number. Platform-specific - **Windows:** Unsupported. | **Source**: | | []()`isDirectory` | `boolean` | True if this is info for a regular directory. Mutually exclusive to `FileInfo.isFile` and `FileInfo.isSymlink`. | **Source**: | | []()`isFile` | `boolean` | True if this is info for a regular file. Mutually exclusive to `FileInfo.isDirectory` and `FileInfo.isSymlink`. | **Source**: | | []()`isSymlink` | `boolean` | True if this is info for a symlink. Mutually exclusive to `FileInfo.isFile` and `FileInfo.isDirectory`. | **Source**: | | []()`mode` | `null` \| `number` | The underlying raw `st_mode` bits that contain the standard Unix permissions for this file/directory. Platform-specific - **Windows:** Unsupported. | **Source**: | | []()`mtime` | `null` \| [`Date`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date) | The last modification time of the file. This corresponds to the `mtime` field from `stat` on Linux/Mac OS and `ftLastWriteTime` on Windows. This may not be available on all platforms. | **Source**: | | []()`nlink` | `null` \| `number` | Number of hard links pointing to this file. Platform-specific - **Windows:** Unsupported. | **Source**: | | []()`rdev` | `null` \| `number` | Device ID of this file. Platform-specific - **Windows:** Unsupported. | **Source**: | | []()`readonly` | `boolean` | Whether this is a readonly (unwritable) file. | **Source**: | | []()`size` | `number` | The size of the file, in bytes. | **Source**: | | []()`uid` | `null` \| `number` | User ID of the owner of this file. Platform-specific - **Windows:** Unsupported. | **Source**: | *** []() ### MkdirOptions #### Since 2.0.0 #### Properties | Property | Type | Description | Defined in | | ---------------- | ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | | []()`baseDir?` | [`BaseDirectory`](/reference/javascript/fs/#basedirectory) | Base directory for `path` | **Source**: | | []()`mode?` | `number` | Permissions to use when creating the directory (defaults to `0o777`, before the process’s umask). Ignored on Windows. | **Source**: | | []()`recursive?` | `boolean` | Defaults to `false`. If set to `true`, means that any intermediate directories will also be created (as with the shell command `mkdir -p`). | **Source**: | *** []() ### OpenOptions #### Since 2.0.0 #### Properties | Property | Type | Description | Defined in | | ---------------- | ---------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | | []()`append?` | `boolean` | Sets the option for the append mode. This option, when `true`, means that writes will append to a file instead of overwriting previous contents. Note that setting `{ write: true, append: true }` has the same effect as setting only `{ append: true }`. | **Source**: | | []()`baseDir?` | [`BaseDirectory`](/reference/javascript/fs/#basedirectory) | Base directory for `path` | **Source**: | | []()`create?` | `boolean` | Sets the option to allow creating a new file, if one doesn’t already exist at the specified path. Requires write or append access to be used. | **Source**: | | []()`createNew?` | `boolean` | Defaults to `false`. If set to `true`, no file, directory, or symlink is allowed to exist at the target location. Requires write or append access to be used. When createNew is set to `true`, create and truncate are ignored. | **Source**: | | []()`mode?` | `number` | Permissions to use if creating the file (defaults to `0o666`, before the process’s umask). Ignored on Windows. | **Source**: | | []()`read?` | `boolean` | Sets the option for read access. This option, when `true`, means that the file should be read-able if opened. | **Source**: | | []()`truncate?` | `boolean` | Sets the option for truncating a previous file. If a file is successfully opened with this option set it will truncate the file to `0` size if it already exists. The file must be opened with write access for truncate to work. | **Source**: | | []()`write?` | `boolean` | Sets the option for write access. This option, when `true`, means that the file should be write-able if opened. If the file already exists, any write calls on it will overwrite its contents, by default without truncating it. | **Source**: | *** []() ### ReadDirOptions #### Since 2.0.0 #### Properties | Property | Type | Description | Defined in | | -------------- | ---------------------------------------------------------- | ------------------------- | ------------------------------------------------------------------------------------------------------- | | []()`baseDir?` | [`BaseDirectory`](/reference/javascript/fs/#basedirectory) | Base directory for `path` | **Source**: | *** []() ### ReadFileOptions #### Since 2.0.0 #### Properties | Property | Type | Description | Defined in | | --------------- | ---------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | | []()`baseDir?` | [`BaseDirectory`](/reference/javascript/fs/#basedirectory) | Base directory for `path` | **Source**: | | []()`encoding?` | `string` | Text encoding to use when reading a text file. Defaults to ‘utf-8’. | **Source**: | *** []() ### RemoveOptions #### Since 2.0.0 #### Properties | Property | Type | Description | Defined in | | ---------------- | ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | | []()`baseDir?` | [`BaseDirectory`](/reference/javascript/fs/#basedirectory) | Base directory for `path` | **Source**: | | []()`recursive?` | `boolean` | Defaults to `false`. If set to `true`, path will be removed even if it’s a non-empty directory. | **Source**: | *** []() ### RenameOptions #### Since 2.0.0 #### Properties | Property | Type | Description | Defined in | | --------------------- | ---------------------------------------------------------- | ----------------------------- | ------------------------------------------------------------------------------------------------------- | | []()`newPathBaseDir?` | [`BaseDirectory`](/reference/javascript/fs/#basedirectory) | Base directory for `newPath`. | **Source**: | | []()`oldPathBaseDir?` | [`BaseDirectory`](/reference/javascript/fs/#basedirectory) | Base directory for `oldPath`. | **Source**: | *** []() ### StatOptions #### Since 2.0.0 #### Properties | Property | Type | Description | Defined in | | -------------- | ---------------------------------------------------------- | -------------------------- | ------------------------------------------------------------------------------------------------------- | | []()`baseDir?` | [`BaseDirectory`](/reference/javascript/fs/#basedirectory) | Base directory for `path`. | **Source**: | *** []() ### TruncateOptions #### Since 2.0.0 #### Properties | Property | Type | Description | Defined in | | -------------- | ---------------------------------------------------------- | -------------------------- | -------------------------------------------------------------------------------------------------------- | | []()`baseDir?` | [`BaseDirectory`](/reference/javascript/fs/#basedirectory) | Base directory for `path`. | **Source**: | *** []() ### WatchEvent #### Since 2.0.0 #### Properties | Property | Type | Defined in | | ----------- | ------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------- | | []()`attrs` | `unknown` | **Source**: | | []()`paths` | `string`\[] | **Source**: | | []()`type` | [`WatchEventKind`](/reference/javascript/fs/#watcheventkind) | **Source**: | *** []() ### WatchOptions #### Since 2.0.0 #### Extended by * [`DebouncedWatchOptions`](/reference/javascript/fs/#debouncedwatchoptions) #### Properties | Property | Type | Description | Defined in | | ---------------- | ---------------------------------------------------------- | ----------------------------- | -------------------------------------------------------------------------------------------------------- | | []()`baseDir?` | [`BaseDirectory`](/reference/javascript/fs/#basedirectory) | Base directory for `path` | **Source**: | | []()`recursive?` | `boolean` | Watch a directory recursively | **Source**: | *** []() ### WriteFileOptions #### Since 2.0.0 #### Properties | Property | Type | Description | Defined in | | ---------------- | ---------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | | []()`append?` | `boolean` | Defaults to `false`. If set to `true`, will append to a file instead of overwriting previous contents. | **Source**: | | []()`baseDir?` | [`BaseDirectory`](/reference/javascript/fs/#basedirectory) | Base directory for `path` | **Source**: | | []()`create?` | `boolean` | Sets the option to allow creating a new file, if one doesn’t already exist at the specified path (defaults to `true`). | **Source**: | | []()`createNew?` | `boolean` | Sets the option to create a new file, failing if it already exists. | **Source**: | | []()`mode?` | `number` | File permissions. Ignored on Windows. | **Source**: | ## Type Aliases []() ### UnwatchFn() ```ts type UnwatchFn: () => void; ``` #### Returns `void` #### Since 2.0.0 **Source**: *** []() ### WatchEventKind ```ts type WatchEventKind: | "any" | object | object | object | object | "other"; ``` #### Since 2.0.0 **Source**: *** []() ### WatchEventKindAccess ```ts type WatchEventKindAccess: object | object | object | object; ``` #### Since 2.0.0 **Source**: *** []() ### WatchEventKindCreate ```ts type WatchEventKindCreate: object | object | object | object; ``` #### Since 2.0.0 **Source**: *** []() ### WatchEventKindModify ```ts type WatchEventKindModify: | object | object | object | object | object; ``` #### Since 2.0.0 **Source**: *** []() ### WatchEventKindRemove ```ts type WatchEventKindRemove: object | object | object | object; ``` #### Since 2.0.0 **Source**: ## Functions []() ### copyFile() ```ts function copyFile( fromPath, toPath, options?): Promise ``` Copies the contents and permissions of one file to another specified path, by default creating a new file if needed, else overwriting. #### Parameters | Parameter | Type | | ---------- | ------------------------------------------------------------------- | | `fromPath` | `string` \| [`URL`](https://developer.mozilla.org/docs/Web/API/URL) | | `toPath` | `string` \| [`URL`](https://developer.mozilla.org/docs/Web/API/URL) | | `options`? | [`CopyFileOptions`](/reference/javascript/fs/#copyfileoptions) | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> #### Example ```typescript import { copyFile, BaseDirectory } from '@tauri-apps/plugin-fs'; await copyFile('app.conf', 'app.conf.bk', { fromPathBaseDir: BaseDirectory.AppConfig, toPathBaseDir: BaseDirectory.AppConfig }); ``` #### Since 2.0.0 **Source**: *** []() ### create() ```ts function create(path, options?): Promise ``` Creates a file if none exists or truncates an existing file and resolves to an instance of [`FileHandle`](/reference/javascript/fs/#filehandle). #### Parameters | Parameter | Type | | ---------- | ------------------------------------------------------------------- | | `path` | `string` \| [`URL`](https://developer.mozilla.org/docs/Web/API/URL) | | `options`? | [`CreateOptions`](/reference/javascript/fs/#createoptions) | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`FileHandle`](/reference/javascript/fs/#filehandle)> #### Example ```typescript import { create, BaseDirectory } from "@tauri-apps/plugin-fs" const file = await create("foo/bar.txt", { baseDir: BaseDirectory.AppConfig }); await file.write(new TextEncoder().encode("Hello world")); await file.close(); ``` #### Since 2.0.0 **Source**: *** []() ### exists() ```ts function exists(path, options?): Promise ``` Check if a path exists. #### Parameters | Parameter | Type | | ---------- | ------------------------------------------------------------------- | | `path` | `string` \| [`URL`](https://developer.mozilla.org/docs/Web/API/URL) | | `options`? | [`ExistsOptions`](/reference/javascript/fs/#existsoptions) | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> #### Example ```typescript import { exists, BaseDirectory } from '@tauri-apps/plugin-fs'; // Check if the `$APPDATA/avatar.png` file exists await exists('avatar.png', { baseDir: BaseDirectory.AppData }); ``` #### Since 2.0.0 **Source**: *** []() ### lstat() ```ts function lstat(path, options?): Promise ``` Resolves to a [`FileInfo`](/reference/javascript/fs/#fileinfo) for the specified `path`. If `path` is a symlink, information for the symlink will be returned instead of what it points to. #### Parameters | Parameter | Type | | ---------- | ------------------------------------------------------------------- | | `path` | `string` \| [`URL`](https://developer.mozilla.org/docs/Web/API/URL) | | `options`? | [`StatOptions`](/reference/javascript/fs/#statoptions) | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`FileInfo`](/reference/javascript/fs/#fileinfo)> #### Example ```typescript import { lstat, BaseDirectory } from '@tauri-apps/plugin-fs'; const fileInfo = await lstat("hello.txt", { baseDir: BaseDirectory.AppLocalData }); console.log(fileInfo.isFile); // true ``` #### Since 2.0.0 **Source**: *** []() ### mkdir() ```ts function mkdir(path, options?): Promise ``` Creates a new directory with the specified path. #### Parameters | Parameter | Type | | ---------- | ------------------------------------------------------------------- | | `path` | `string` \| [`URL`](https://developer.mozilla.org/docs/Web/API/URL) | | `options`? | [`MkdirOptions`](/reference/javascript/fs/#mkdiroptions) | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> #### Example ```typescript import { mkdir, BaseDirectory } from '@tauri-apps/plugin-fs'; await mkdir('users', { baseDir: BaseDirectory.AppLocalData }); ``` #### Since 2.0.0 **Source**: *** []() ### open() ```ts function open(path, options?): Promise ``` Open a file and resolve to an instance of [`FileHandle`](/reference/javascript/fs/#filehandle). The file does not need to previously exist if using the `create` or `createNew` open options. It is the callers responsibility to close the file when finished with it. #### Parameters | Parameter | Type | | ---------- | ------------------------------------------------------------------- | | `path` | `string` \| [`URL`](https://developer.mozilla.org/docs/Web/API/URL) | | `options`? | [`OpenOptions`](/reference/javascript/fs/#openoptions) | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`FileHandle`](/reference/javascript/fs/#filehandle)> #### Example ```typescript import { open, BaseDirectory } from "@tauri-apps/plugin-fs" const file = await open("foo/bar.txt", { read: true, write: true, baseDir: BaseDirectory.AppLocalData }); // Do work with file await file.close(); ``` #### Since 2.0.0 **Source**: *** []() ### readDir() ```ts function readDir(path, options?): Promise ``` Reads the directory given by path and returns an array of `DirEntry`. #### Parameters | Parameter | Type | | ---------- | ------------------------------------------------------------------- | | `path` | `string` \| [`URL`](https://developer.mozilla.org/docs/Web/API/URL) | | `options`? | [`ReadDirOptions`](/reference/javascript/fs/#readdiroptions) | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`DirEntry`](/reference/javascript/fs/#direntry)\[]> #### Example ```typescript import { readDir, BaseDirectory } from '@tauri-apps/plugin-fs'; import { join } from '@tauri-apps/api/path'; const dir = "users" const entries = await readDir('users', { baseDir: BaseDirectory.AppLocalData }); processEntriesRecursively(dir, entries); async function processEntriesRecursively(parent, entries) { for (const entry of entries) { console.log(`Entry: ${entry.name}`); if (entry.isDirectory) { const dir = await join(parent, entry.name); processEntriesRecursively(dir, await readDir(dir, { baseDir: BaseDirectory.AppLocalData })) } } } ``` #### Since 2.0.0 **Source**: *** []() ### readFile() ```ts function readFile(path, options?): Promise ``` Reads and resolves to the entire contents of a file as an array of bytes. TextDecoder can be used to transform the bytes to string if required. #### Parameters | Parameter | Type | | ---------- | ------------------------------------------------------------------- | | `path` | `string` \| [`URL`](https://developer.mozilla.org/docs/Web/API/URL) | | `options`? | [`ReadFileOptions`](/reference/javascript/fs/#readfileoptions) | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)> #### Example ```typescript import { readFile, BaseDirectory } from '@tauri-apps/plugin-fs'; const contents = await readFile('avatar.png', { baseDir: BaseDirectory.Resource }); ``` #### Since 2.0.0 **Source**: *** []() ### readTextFile() ```ts function readTextFile(path, options?): Promise ``` Reads and returns the entire contents of a file as a string using the specified encoding (default: UTF-8). #### Parameters | Parameter | Type | | ---------- | ------------------------------------------------------------------- | | `path` | `string` \| [`URL`](https://developer.mozilla.org/docs/Web/API/URL) | | `options`? | [`ReadFileOptions`](/reference/javascript/fs/#readfileoptions) | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> #### Example ```typescript import { readTextFile, BaseDirectory } from '@tauri-apps/plugin-fs'; const contents = await readTextFile('app.conf', { baseDir: BaseDirectory.AppConfig }); ``` #### Since 2.0.0 **Source**: *** []() ### readTextFileLines() ```ts function readTextFileLines(path, options?): Promise> ``` Returns an async AsyncIterableIterator over the lines of a file, decoded using the specified encoding (default: UTF-8). #### Parameters | Parameter | Type | | ---------- | ------------------------------------------------------------------- | | `path` | `string` \| [`URL`](https://developer.mozilla.org/docs/Web/API/URL) | | `options`? | [`ReadFileOptions`](/reference/javascript/fs/#readfileoptions) | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`AsyncIterableIterator`<`string`>> #### Example ```typescript import { readTextFileLines, BaseDirectory } from '@tauri-apps/plugin-fs'; const lines = await readTextFileLines('app.conf', { baseDir: BaseDirectory.AppConfig }); for await (const line of lines) { console.log(line); } ``` You could also call AsyncIterableIterator.next to advance the iterator so you can lazily read the next line whenever you want. #### Since 2.0.0 **Source**: *** []() ### remove() ```ts function remove(path, options?): Promise ``` Removes the named file or directory. If the directory is not empty and the `recursive` option isn’t set to true, the promise will be rejected. #### Parameters | Parameter | Type | | ---------- | ------------------------------------------------------------------- | | `path` | `string` \| [`URL`](https://developer.mozilla.org/docs/Web/API/URL) | | `options`? | [`RemoveOptions`](/reference/javascript/fs/#removeoptions) | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> #### Example ```typescript import { remove, BaseDirectory } from '@tauri-apps/plugin-fs'; await remove('users/file.txt', { baseDir: BaseDirectory.AppLocalData }); await remove('users', { baseDir: BaseDirectory.AppLocalData }); ``` #### Since 2.0.0 **Source**: *** []() ### rename() ```ts function rename( oldPath, newPath, options?): Promise ``` Renames (moves) oldpath to newpath. Paths may be files or directories. If newpath already exists and is not a directory, rename() replaces it. OS-specific restrictions may apply when oldpath and newpath are in different directories. On Unix, this operation does not follow symlinks at either path. #### Parameters | Parameter | Type | | ---------- | ------------------------------------------------------------------- | | `oldPath` | `string` \| [`URL`](https://developer.mozilla.org/docs/Web/API/URL) | | `newPath` | `string` \| [`URL`](https://developer.mozilla.org/docs/Web/API/URL) | | `options`? | [`RenameOptions`](/reference/javascript/fs/#renameoptions) | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> #### Example ```typescript import { rename, BaseDirectory } from '@tauri-apps/plugin-fs'; await rename('avatar.png', 'deleted.png', { oldPathBaseDir: BaseDirectory.App, newPathBaseDir: BaseDirectory.AppLocalData }); ``` #### Since 2.0.0 **Source**: *** []() ### size() ```ts function size(path): Promise ``` Get the size of a file or directory. For files, the `stat` functions can be used as well. If `path` is a directory, this function will recursively iterate over every file and every directory inside of `path` and therefore will be very time consuming if used on larger directories. #### Parameters | Parameter | Type | | --------- | ------------------------------------------------------------------- | | `path` | `string` \| [`URL`](https://developer.mozilla.org/docs/Web/API/URL) | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`number`> #### Example ```typescript import { size, BaseDirectory } from '@tauri-apps/plugin-fs'; // Get the size of the `$APPDATA/tauri` directory. const dirSize = await size('tauri', { baseDir: BaseDirectory.AppData }); console.log(dirSize); // 1024 ``` #### Since 2.1.0 **Source**: *** []() ### startAccessingSecurityScopedResource() ```ts function startAccessingSecurityScopedResource(path): Promise ``` Starts accessing a security-scoped resource for the given file URL. This should be called when you’re accessing a file that was opened using a security-scoped URL (e.g., from a file picker). Note that accessing security-scoped resources is automatically managed by the plugin on iOS, so you don’t need to call this function unless you want to manage the scope manually. You must call [`stopAccessingSecurityScopedResource`](/reference/javascript/fs/#stopaccessingsecurityscopedresource) when you’re done accessing the resource. Platform-specific * **iOS:** Starts accessing the security-scoped resource. * **Other platforms:** does nothing. #### Parameters | Parameter | Type | | --------- | ------------------------------------------------------------------- | | `path` | `string` \| [`URL`](https://developer.mozilla.org/docs/Web/API/URL) | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> #### Example ```typescript import { startAccessingSecurityScopedResource } from '@tauri-apps/plugin-fs'; const filePath = 'file:///path/to/file.txt'; await startAccessingSecurityScopedResource(filePath); // ... use the resource ... ``` #### Since 2.5.0 **Source**: *** []() ### stat() ```ts function stat(path, options?): Promise ``` Resolves to a [`FileInfo`](/reference/javascript/fs/#fileinfo) for the specified `path`. Will always follow symlinks but will reject if the symlink points to a path outside of the scope. #### Parameters | Parameter | Type | | ---------- | ------------------------------------------------------------------- | | `path` | `string` \| [`URL`](https://developer.mozilla.org/docs/Web/API/URL) | | `options`? | [`StatOptions`](/reference/javascript/fs/#statoptions) | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`FileInfo`](/reference/javascript/fs/#fileinfo)> #### Example ```typescript import { stat, BaseDirectory } from '@tauri-apps/plugin-fs'; const fileInfo = await stat("hello.txt", { baseDir: BaseDirectory.AppLocalData }); console.log(fileInfo.isFile); // true ``` #### Since 2.0.0 **Source**: *** []() ### stopAccessingSecurityScopedResource() ```ts function stopAccessingSecurityScopedResource(path): Promise ``` Stops accessing a security-scoped resource for the given file URL. This should be called when you’re done accessing a file that was opened using a security-scoped URL (e.g., from a file picker) when using manual tracking via [`startAccessingSecurityScopedResource`](/reference/javascript/fs/#startaccessingsecurityscopedresource). Platform-specific * **iOS:** Stops accessing the security-scoped resource. * **Other platforms:** does nothing. #### Parameters | Parameter | Type | | --------- | ------------------------------------------------------------------- | | `path` | `string` \| [`URL`](https://developer.mozilla.org/docs/Web/API/URL) | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> #### Example ```typescript import { stopAccessingSecurityScopedResource } from '@tauri-apps/plugin-fs'; const filePath = 'file:///path/to/file.txt'; await startAccessingSecurityScopedResource(filePath); // ... use the resource ... // when you're done with the resource: await stopAccessingSecurityScopedResource(filePath); ``` #### Since 2.5.0 **Source**: *** []() ### truncate() ```ts function truncate( path, len?, options?): Promise ``` Truncates or extends the specified file, to reach the specified `len`. If `len` is `0` or not specified, then the entire file contents are truncated. #### Parameters | Parameter | Type | | ---------- | ------------------------------------------------------------------- | | `path` | `string` \| [`URL`](https://developer.mozilla.org/docs/Web/API/URL) | | `len`? | `number` | | `options`? | [`TruncateOptions`](/reference/javascript/fs/#truncateoptions) | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> #### Example ```typescript import { truncate, readTextFile, writeTextFile, BaseDirectory } from '@tauri-apps/plugin-fs'; // truncate the entire file await truncate("my_file.txt", 0, { baseDir: BaseDirectory.AppLocalData }); // truncate part of the file const filePath = "file.txt"; await writeTextFile(filePath, "Hello World", { baseDir: BaseDirectory.AppLocalData }); await truncate(filePath, 7, { baseDir: BaseDirectory.AppLocalData }); const data = await readTextFile(filePath, { baseDir: BaseDirectory.AppLocalData }); console.log(data); // "Hello W" ``` #### Since 2.0.0 **Source**: *** []() ### watch() ```ts function watch( paths, cb, options?): Promise ``` Watch changes (after a delay) on files or directories. #### Parameters | Parameter | Type | | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | | `paths` | `string` \| [`URL`](https://developer.mozilla.org/docs/Web/API/URL) \| `string`\[] \| [`URL`](https://developer.mozilla.org/docs/Web/API/URL)\[] | | `cb` | (`event`) => `void` | | `options`? | [`DebouncedWatchOptions`](/reference/javascript/fs/#debouncedwatchoptions) | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`UnwatchFn`](/reference/javascript/fs/#unwatchfn)> #### Since 2.0.0 **Source**: *** []() ### watchImmediate() ```ts function watchImmediate( paths, cb, options?): Promise ``` Watch changes on files or directories. #### Parameters | Parameter | Type | | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | | `paths` | `string` \| [`URL`](https://developer.mozilla.org/docs/Web/API/URL) \| `string`\[] \| [`URL`](https://developer.mozilla.org/docs/Web/API/URL)\[] | | `cb` | (`event`) => `void` | | `options`? | [`WatchOptions`](/reference/javascript/fs/#watchoptions) | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`UnwatchFn`](/reference/javascript/fs/#unwatchfn)> #### Since 2.0.0 **Source**: *** []() ### writeFile() ```ts function writeFile( path, data, options?): Promise ``` Write `data` to the given `path`, by default creating a new file if needed, else overwriting. #### Parameters | Parameter | Type | | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `path` | `string` \| [`URL`](https://developer.mozilla.org/docs/Web/API/URL) | | `data` | [`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) \| [`ReadableStream`](https://developer.mozilla.org/docs/Web/API/ReadableStream)<[`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)> | | `options`? | [`WriteFileOptions`](/reference/javascript/fs/#writefileoptions) | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> #### Example ```typescript import { writeFile, BaseDirectory } from '@tauri-apps/plugin-fs'; let encoder = new TextEncoder(); let data = encoder.encode("Hello World"); await writeFile('file.txt', data, { baseDir: BaseDirectory.AppLocalData }); ``` #### Since 2.0.0 **Source**: *** []() ### writeTextFile() ```ts function writeTextFile( path, data, options?): Promise ``` Writes UTF-8 string `data` to the given `path`, by default creating a new file if needed, else overwriting. #### Parameters | Parameter | Type | | ---------- | ------------------------------------------------------------------- | | `path` | `string` \| [`URL`](https://developer.mozilla.org/docs/Web/API/URL) | | `data` | `string` | | `options`? | [`WriteFileOptions`](/reference/javascript/fs/#writefileoptions) | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> #### Example ```typescript import { writeTextFile, BaseDirectory } from '@tauri-apps/plugin-fs'; await writeTextFile('file.txt', "Hello world", { baseDir: BaseDirectory.AppLocalData }); ``` #### Since 2.0.0 **Source**: # @tauri-apps/plugin-geolocation ## Type Aliases []() ### Coordinates ```ts type Coordinates: object; ``` #### Type declaration | Name | Type | Description | Defined in | | ------------------ | ------------------ | ---------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | | `accuracy` | `number` | Accuracy level of the latitude and longitude coordinates in meters. | **Source**: | | `altitude` | `number` \| `null` | The altitude the user is at, if available. | **Source**: | | `altitudeAccuracy` | `number` \| `null` | Accuracy level of the altitude coordinate in meters, if available. Available on all iOS versions and on Android 8 and above. | **Source**: | | `heading` | `number` \| `null` | The heading the user is facing, if available. | **Source**: | | `latitude` | `number` | Latitude in decimal degrees. | **Source**: | | `longitude` | `number` | Longitude in decimal degrees. | **Source**: | | `speed` | `number` \| `null` | - | **Source**: | **Source**: *** []() ### PermissionStatus ```ts type PermissionStatus: object; ``` #### Type declaration | Name | Type | Description | Defined in | | ---------------- | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | | `coarseLocation` | `PermissionState` | Permissions state for the coarseLoaction alias. On Android it requests/checks ACCESS\_COARSE\_LOCATION. On Android 12+, users can choose between Approximate location (ACCESS\_COARSE\_LOCATION) and Precise location (ACCESS\_FINE\_LOCATION). On iOS it will have the same value as the `location` alias. | **Source**: | | `location` | `PermissionState` | Permission state for the location alias. On Android it requests/checks both ACCESS\_COARSE\_LOCATION and ACCESS\_FINE\_LOCATION permissions. On iOS it requests/checks location permissions. | **Source**: | **Source**: *** []() ### PermissionType ```ts type PermissionType: "location" | "coarseLocation"; ``` **Source**: *** []() ### Position ```ts type Position: object; ``` #### Type declaration | Name | Type | Description | Defined in | | ----------- | --------------------------------------------------------------- | -------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | | `coords` | [`Coordinates`](/reference/javascript/geolocation/#coordinates) | The GPD coordinates along with the accuracy of the data. | **Source**: | | `timestamp` | `number` | Creation time for these coordinates. | **Source**: | **Source**: *** []() ### PositionOptions ```ts type PositionOptions: object; ``` #### Type declaration | Name | Type | Description | Defined in | | -------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------- | | `enableHighAccuracy` | `boolean` | High accuracy mode (such as GPS, if available) Will be ignored on Android 12+ if users didn’t grant the ACCESS\_FINE\_LOCATION permission (`coarseLocation` permission). | **Source**: | | `maximumAge` | `number` | The maximum age in milliseconds of a possible cached position that is acceptable to return. Default: 0 Ignored on iOS | **Source**: | | `timeout` | `number` | The maximum wait time in milliseconds for location updates. On Android the timeout gets ignored for getCurrentPosition. Ignored on iOS | **Source**: | **Source**: ## Functions []() ### checkPermissions() ```ts function checkPermissions(): Promise ``` #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`PermissionStatus`](/reference/javascript/geolocation/#permissionstatus)> **Source**: *** []() ### clearWatch() ```ts function clearWatch(channelId): Promise ``` #### Parameters | Parameter | Type | | ----------- | -------- | | `channelId` | `number` | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: *** []() ### getCurrentPosition() ```ts function getCurrentPosition(options?): Promise ``` #### Parameters | Parameter | Type | | ---------- | ----------------------------------------------------------------------- | | `options`? | [`PositionOptions`](/reference/javascript/geolocation/#positionoptions) | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Position`](/reference/javascript/geolocation/#position)> **Source**: *** []() ### requestPermissions() ```ts function requestPermissions(permissions): Promise ``` #### Parameters | Parameter | Type | | ------------- | ---------------------------------------------------------------------------------- | | `permissions` | `null` \| [`PermissionType`](/reference/javascript/geolocation/#permissiontype)\[] | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`PermissionStatus`](/reference/javascript/geolocation/#permissionstatus)> **Source**: *** []() ### watchPosition() ```ts function watchPosition(options, cb): Promise ``` #### Parameters | Parameter | Type | | --------- | ----------------------------------------------------------------------- | | `options` | [`PositionOptions`](/reference/javascript/geolocation/#positionoptions) | | `cb` | (`location`, `error`?) => `void` | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`number`> **Source**: # @tauri-apps/plugin-global-shortcut Register global shortcuts. ## Interfaces []() ### ShortcutEvent #### Properties | Property | Type | Defined in | | -------------- | --------------------------- | ------------------------------------------------------------------------------------------------------------------- | | []()`id` | `number` | **Source**: | | []()`shortcut` | `string` | **Source**: | | []()`state` | `"Released"` \| `"Pressed"` | **Source**: | ## Type Aliases []() ### ShortcutHandler() ```ts type ShortcutHandler: (event) => void; ``` #### Parameters | Parameter | Type | | --------- | ----------------------------------------------------------------------- | | `event` | [`ShortcutEvent`](/reference/javascript/global-shortcut/#shortcutevent) | #### Returns `void` **Source**: ## Functions []() ### isRegistered() ```ts function isRegistered(shortcut): Promise ``` Determines whether the given shortcut is registered by this application or not. If the shortcut is registered by another application, it will still return `false`. #### Parameters | Parameter | Type | Description | | ---------- | -------- | --------------------------------------------------------------------------- | | `shortcut` | `string` | shortcut definition, modifiers and key separated by “+” e.g. CmdOrControl+Q | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> #### Example ```typescript import { isRegistered } from '@tauri-apps/plugin-global-shortcut'; const isRegistered = await isRegistered('CommandOrControl+P'); ``` #### Since 2.0.0 **Source**: *** []() ### register() ```ts function register(shortcuts, handler): Promise ``` Register a global shortcut or a list of shortcuts. The handler is called when any of the registered shortcuts are pressed by the user. If the shortcut is already taken by another application, the handler will not be triggered. Make sure the shortcut is as unique as possible while still taking user experience into consideration. #### Parameters | Parameter | Type | Description | | ----------- | --------------------------------------------------------------------------- | -------------------------------------------------------------------- | | `shortcuts` | `string` \| `string`\[] | - | | `handler` | [`ShortcutHandler`](/reference/javascript/global-shortcut/#shortcuthandler) | Shortcut handler callback - takes the triggered shortcut as argument | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> #### Example ```typescript import { register } from '@tauri-apps/plugin-global-shortcut'; // register a single hotkey await register('CommandOrControl+Shift+C', (event) => { if (event.state === "Pressed") { console.log('Shortcut triggered'); } }); // or register multiple hotkeys at once await register(['CommandOrControl+Shift+C', 'Alt+A'], (event) => { console.log(`Shortcut ${event.shortcut} triggered`); }); ``` #### Since 2.0.0 **Source**: *** []() ### unregister() ```ts function unregister(shortcuts): Promise ``` Unregister a global shortcut or a list of shortcuts. #### Parameters | Parameter | Type | | ----------- | ----------------------- | | `shortcuts` | `string` \| `string`\[] | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> #### Example ```typescript import { unregister } from '@tauri-apps/plugin-global-shortcut'; // unregister a single hotkey await unregister('CmdOrControl+Space'); // or unregister multiple hotkeys at the same time await unregister(['CmdOrControl+Space', 'Alt+A']); ``` #### Since 2.0.0 **Source**: *** []() ### unregisterAll() ```ts function unregisterAll(): Promise ``` Unregister all global shortcuts. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> #### Example ```typescript import { unregisterAll } from '@tauri-apps/plugin-global-shortcut'; await unregisterAll(); ``` #### Since 2.0.0 **Source**: # @tauri-apps/plugin-haptics ## Type Aliases []() ### ImpactFeedbackStyle ```ts type ImpactFeedbackStyle: | "light" | "medium" | "heavy" | "soft" | "rigid"; ``` **Source**: *** []() ### NotificationFeedbackType ```ts type NotificationFeedbackType: "success" | "warning" | "error"; ``` **Source**: ## Functions []() ### impactFeedback() ```ts function impactFeedback(style): Promise> ``` #### Parameters | Parameter | Type | | --------- | --------------------------------------------------------------------------- | | `style` | [`ImpactFeedbackStyle`](/reference/javascript/haptics/#impactfeedbackstyle) | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`Result`<`null`, `never`>> **Source**: *** []() ### notificationFeedback() ```ts function notificationFeedback(type): Promise> ``` #### Parameters | Parameter | Type | | --------- | ------------------------------------------------------------------------------------- | | `type` | [`NotificationFeedbackType`](/reference/javascript/haptics/#notificationfeedbacktype) | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`Result`<`null`, `never`>> **Source**: *** []() ### selectionFeedback() ```ts function selectionFeedback(): Promise> ``` #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`Result`<`null`, `never`>> **Source**: *** []() ### vibrate() ```ts function vibrate(duration): Promise> ``` #### Parameters | Parameter | Type | | ---------- | -------- | | `duration` | `number` | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`Result`<`null`, `never`>> **Source**: # @tauri-apps/plugin-http Make HTTP requests with the Rust backend. ## Security This API has a scope configuration that forces you to restrict the URLs that can be accessed using glob patterns. For instance, this scope configuration only allows making HTTP requests to all subdomains for `tauri.app` except for `https://private.tauri.app`: ```json { "permissions": [ { "identifier": "http:default", "allow": [{ "url": "https://*.tauri.app" }], "deny": [{ "url": "https://private.tauri.app" }] } ] } ``` Trying to execute any API with a URL not configured on the scope results in a promise rejection due to denied access. ## Interfaces []() ### ClientOptions Options to configure the Rust client used to make fetch requests #### Since 2.0.0 #### Properties | Property | Type | Description | Defined in | | ---------------------- | -------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | | []()`connectTimeout?` | `number` | Timeout in milliseconds | **Source**: | | []()`danger?` | [`DangerousSettings`](/reference/javascript/http/#dangeroussettings) | Configuration for dangerous settings on the client such as disabling SSL verification. | **Source**: | | []()`maxRedirections?` | `number` | Defines the maximum number of redirects the client should follow. If set to 0, no redirects will be followed. | **Source**: | | []()`proxy?` | [`Proxy`](/reference/javascript/http/#proxy-1) | Configuration of a proxy that a Client should pass requests to. | **Source**: | *** []() ### DangerousSettings Configuration for dangerous settings on the client such as disabling SSL verification. #### Since 2.3.0 #### Properties | Property | Type | Description | Defined in | | ----------------------------- | --------- | ------------------------------- | --------------------------------------------------------------------------------------------------------- | | []()`acceptInvalidCerts?` | `boolean` | Disables SSL verification. | **Source**: | | []()`acceptInvalidHostnames?` | `boolean` | Disables hostname verification. | **Source**: | *** []() ### Proxy Configuration of a proxy that a Client should pass requests to. #### Since 2.0.0 #### Properties | Property | Type | Description | Defined in | | ------------ | -------------------------------------------------------------------- | ------------------------------------------ | -------------------------------------------------------------------------------------------------------- | | []()`all?` | `string` \| [`ProxyConfig`](/reference/javascript/http/#proxyconfig) | Proxy all traffic to the passed URL. | **Source**: | | []()`http?` | `string` \| [`ProxyConfig`](/reference/javascript/http/#proxyconfig) | Proxy all HTTP traffic to the passed URL. | **Source**: | | []()`https?` | `string` \| [`ProxyConfig`](/reference/javascript/http/#proxyconfig) | Proxy all HTTPS traffic to the passed URL. | **Source**: | *** []() ### ProxyConfig #### Properties | Property | Type | Description | Defined in | | ------------------------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | | []()`basicAuth?` | `object` | Set the `Proxy-Authorization` header using Basic auth. | **Source**: | | []()`basicAuth.password` | `string` | - | **Source**: | | []()`basicAuth.username` | `string` | - | **Source**: | | []()`noProxy?` | `string` | A configuration for filtering out requests that shouldn’t be proxied. Entries are expected to be comma-separated (whitespace between entries is ignored) | **Source**: | | []()`url` | `string` | The URL of the proxy server. | **Source**: | ## Functions []() ### fetch() ```ts function fetch(input, init?): Promise ``` Fetch a resource from the network. It returns a `Promise` that resolves to the `Response` to that `Request`, whether it is successful or not. #### Parameters | Parameter | Type | | --------- | -------------------------------------------------------------------------------------------------------------------------------------- | | `input` | `string` \| [`URL`](https://developer.mozilla.org/docs/Web/API/URL) \| [`Request`](https://developer.mozilla.org/docs/Web/API/Request) | | `init`? | `RequestInit` & [`ClientOptions`](/reference/javascript/http/#clientoptions) | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Response`](https://developer.mozilla.org/docs/Web/API/Response)> #### Example ```typescript const response = await fetch("http://my.json.host/data.json"); console.log(response.status); // e.g. 200 console.log(response.statusText); // e.g. "OK" const jsonData = await response.json(); ``` #### Since 2.0.0 **Source**: # @tauri-apps/plugin-log ## Enumerations []() ### LogLevel #### Enumeration Members []() ##### Debug ```ts Debug: 2; ``` The “debug” level. Designates lower priority information. **Source**: []() ##### Error ```ts Error: 5; ``` The “error” level. Designates very serious errors. **Source**: []() ##### Info ```ts Info: 3; ``` The “info” level. Designates useful information. **Source**: []() ##### Trace ```ts Trace: 1; ``` The “trace” level. Designates very low priority, often extremely verbose, information. **Source**: []() ##### Warn ```ts Warn: 4; ``` The “warn” level. Designates hazardous situations. **Source**: ## Interfaces []() ### LogOptions #### Properties | Property | Type | Defined in | | ---------------- | ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------- | | []()`file?` | `string` | **Source**: | | []()`keyValues?` | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)<`string`, `undefined` \| `string`> | **Source**: | | []()`line?` | `number` | **Source**: | ## Functions []() ### attachConsole() ```ts function attachConsole(): Promise ``` Attaches a listener that writes log entries to the console as they come in. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`UnlistenFn`> a function to cancel the listener. **Source**: *** []() ### attachLogger() ```ts function attachLogger(fn): Promise ``` Attaches a listener for the log, and calls the passed function for each log entry. #### Parameters | Parameter | Type | Description | | --------- | ---------- | ----------- | | `fn` | `LoggerFn` | | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`UnlistenFn`> a function to cancel the listener. **Source**: *** []() ### debug() ```ts function debug(message, options?): Promise ``` Logs a message at the debug level. #### Parameters | Parameter | Type | Description | | ---------- | ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | | `message` | `string` | # Examples `import { debug } from '@tauri-apps/plugin-log'; const pos = { x: 3.234, y: -1.223 }; debug(`New position: x: {pos.x}, y: {pos.y}`);` | | `options`? | [`LogOptions`](/reference/javascript/log/#logoptions) | - | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: *** []() ### error() ```ts function error(message, options?): Promise ``` Logs a message at the error level. #### Parameters | Parameter | Type | Description | | ---------- | ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `message` | `string` | # Examples `import { error } from '@tauri-apps/plugin-log'; const err_info = "No connection"; const port = 22; error(`Error: ${err\_info} on port ${port}`);` | | `options`? | [`LogOptions`](/reference/javascript/log/#logoptions) | - | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: *** []() ### info() ```ts function info(message, options?): Promise ``` Logs a message at the info level. #### Parameters | Parameter | Type | Description | | ---------- | ----------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `message` | `string` | # Examples `import { info } from '@tauri-apps/plugin-log'; const conn_info = { port: 40, speed: 3.20 }; info(`Connected to port {conn\_info.port} at {conn\_info.speed} Mb/s`);` | | `options`? | [`LogOptions`](/reference/javascript/log/#logoptions) | - | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: *** []() ### trace() ```ts function trace(message, options?): Promise ``` Logs a message at the trace level. #### Parameters | Parameter | Type | Description | | ---------- | ----------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | | `message` | `string` | # Examples `import { trace } from '@tauri-apps/plugin-log'; let pos = { x: 3.234, y: -1.223 }; trace(`Position is: x: {pos.x}, y: {pos.y}`);` | | `options`? | [`LogOptions`](/reference/javascript/log/#logoptions) | - | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: *** []() ### warn() ```ts function warn(message, options?): Promise ``` Logs a message at the warn level. #### Parameters | Parameter | Type | Description | | ---------- | ----------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `message` | `string` | # Examples `import { warn } from '@tauri-apps/plugin-log'; const warn_description = "Invalid Input"; warn(`Warning! {warn\_description}!`);` | | `options`? | [`LogOptions`](/reference/javascript/log/#logoptions) | - | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: # @tauri-apps/plugin-nfc ## Enumerations []() ### NFCTypeNameFormat #### Enumeration Members []() ##### AbsoluteURI ```ts AbsoluteURI: 3; ``` **Source**: []() ##### Empty ```ts Empty: 0; ``` **Source**: []() ##### Media ```ts Media: 2; ``` **Source**: []() ##### NfcExternal ```ts NfcExternal: 4; ``` **Source**: []() ##### NfcWellKnown ```ts NfcWellKnown: 1; ``` **Source**: []() ##### Unchanged ```ts Unchanged: 6; ``` **Source**: []() ##### Unknown ```ts Unknown: 5; ``` **Source**: *** []() ### TechKind #### Enumeration Members []() ##### IsoDep ```ts IsoDep: 0; ``` **Source**: []() ##### MifareClassic ```ts MifareClassic: 1; ``` **Source**: []() ##### MifareUltralight ```ts MifareUltralight: 2; ``` **Source**: []() ##### Ndef ```ts Ndef: 3; ``` **Source**: []() ##### NdefFormatable ```ts NdefFormatable: 4; ``` **Source**: []() ##### NfcA ```ts NfcA: 5; ``` **Source**: []() ##### NfcB ```ts NfcB: 6; ``` **Source**: []() ##### NfcBarcode ```ts NfcBarcode: 7; ``` **Source**: []() ##### NfcF ```ts NfcF: 8; ``` **Source**: []() ##### NfcV ```ts NfcV: 9; ``` **Source**: ## Interfaces []() ### NFCRecord #### Properties | Property | Type | Defined in | | ------------- | ------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | | []()`format` | [`NFCTypeNameFormat`](/reference/javascript/nfc/#nfctypenameformat) | **Source**: | | []()`id` | `number`\[] | **Source**: | | []()`kind` | `number`\[] | **Source**: | | []()`payload` | `number`\[] | **Source**: | *** []() ### ScanOptions #### Properties | Property | Type | Description | Defined in | | ----------------------- | --------- | --------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | | []()`keepSessionAlive?` | `boolean` | - | **Source**: | | []()`message?` | `string` | Message displayed in the UI. iOS only. | **Source**: | | []()`successMessage?` | `string` | Message displayed in the UI when the message has been read. iOS only. | **Source**: | *** []() ### Tag #### Properties | Property | Type | Defined in | | ------------- | ------------------------------------------------------ | -------------------------------------------------------------------------------------------------------- | | []()`id` | `number`\[] | **Source**: | | []()`kind` | `string`\[] | **Source**: | | []()`records` | [`TagRecord`](/reference/javascript/nfc/#tagrecord)\[] | **Source**: | *** []() ### TagRecord #### Properties | Property | Type | Defined in | | ------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | | []()`id` | `number`\[] | **Source**: | | []()`kind` | `number`\[] | **Source**: | | []()`payload` | `number`\[] | **Source**: | | []()`tnf` | [`NFCTypeNameFormat`](/reference/javascript/nfc/#nfctypenameformat) | **Source**: | *** []() ### UriFilter #### Properties | Property | Type | Defined in | | ----------------- | -------- | ------------------------------------------------------------------------------------------------------- | | []()`host?` | `string` | **Source**: | | []()`pathPrefix?` | `string` | **Source**: | | []()`scheme?` | `string` | **Source**: | *** []() ### WriteOptions #### Properties | Property | Type | Description | Defined in | | ---------------------------- | ------------------------------------------------- | ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------- | | []()`kind?` | [`ScanKind`](/reference/javascript/nfc/#scankind) | - | **Source**: | | []()`message?` | `string` | Message displayed in the UI when reading the tag. iOS only. | **Source**: | | []()`successMessage?` | `string` | Message displayed in the UI when the message has been written. iOS only. | **Source**: | | []()`successfulReadMessage?` | `string` | Message displayed in the UI when the tag has been read. iOS only. | **Source**: | ## Type Aliases []() ### ScanKind ```ts type ScanKind: object | object; ``` **Source**: ## Variables []() ### RTD\_TEXT ```ts const RTD_TEXT: number[]; ``` **Source**: *** []() ### RTD\_URI ```ts const RTD_URI: number[]; ``` **Source**: ## Functions []() ### isAvailable() ```ts function isAvailable(): Promise ``` #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> **Source**: *** []() ### record() ```ts function record( format, kind, id, payload): NFCRecord ``` #### Parameters | Parameter | Type | | --------- | ------------------------------------------------------------------- | | `format` | [`NFCTypeNameFormat`](/reference/javascript/nfc/#nfctypenameformat) | | `kind` | `string` \| `number`\[] | | `id` | `string` \| `number`\[] | | `payload` | `string` \| `number`\[] | #### Returns [`NFCRecord`](/reference/javascript/nfc/#nfcrecord) **Source**: *** []() ### scan() ```ts function scan(kind, options?): Promise ``` Scans an NFC tag. ```javascript import { scan } from "@tauri-apps/plugin-nfc"; await scan({ type: "tag" }); ``` See for more information. #### Parameters | Parameter | Type | Description | | ---------- | ------------------------------------------------------- | ----------- | | `kind` | [`ScanKind`](/reference/javascript/nfc/#scankind) | | | `options`? | [`ScanOptions`](/reference/javascript/nfc/#scanoptions) | | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Tag`](/reference/javascript/nfc/#tag)> **Source**: *** []() ### textRecord() ```ts function textRecord( text, id?, language?): NFCRecord ``` #### Parameters | Parameter | Type | Default value | | ----------- | ----------------------- | ------------- | | `text` | `string` | `undefined` | | `id`? | `string` \| `number`\[] | `undefined` | | `language`? | `string` | `'en'` | #### Returns [`NFCRecord`](/reference/javascript/nfc/#nfcrecord) **Source**: *** []() ### uriRecord() ```ts function uriRecord(uri, id?): NFCRecord ``` #### Parameters | Parameter | Type | | --------- | ----------------------- | | `uri` | `string` | | `id`? | `string` \| `number`\[] | #### Returns [`NFCRecord`](/reference/javascript/nfc/#nfcrecord) **Source**: *** []() ### write() ```ts function write(records, options?): Promise ``` Write to an NFC tag. ```javascript import { uriRecord, write } from "@tauri-apps/plugin-nfc"; await write([uriRecord("https://tauri.app")], { kind: { type: "ndef" } }); ``` If you did not previously call [scan](/reference/javascript/nfc/#scan) with [ScanOptions.keepSessionAlive](/reference/javascript/nfc/#keepsessionalive) set to true, it will first scan the tag then write to it. #### Parameters | Parameter | Type | Description | | ---------- | --------------------------------------------------------- | ----------- | | `records` | [`NFCRecord`](/reference/javascript/nfc/#nfcrecord)\[] | | | `options`? | [`WriteOptions`](/reference/javascript/nfc/#writeoptions) | | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: # @tauri-apps/plugin-notification Send toast notifications (brief auto-expiring OS window element) to your user. Can also be used with the Notification Web API. ## Enumerations []() ### Importance #### Enumeration Members []() ##### Default ```ts Default: 3; ``` **Source**: []() ##### High ```ts High: 4; ``` **Source**: []() ##### Low ```ts Low: 2; ``` **Source**: []() ##### Min ```ts Min: 1; ``` **Source**: []() ##### None ```ts None: 0; ``` **Source**: *** []() ### ScheduleEvery #### Enumeration Members []() ##### Day ```ts Day: "day"; ``` **Source**: []() ##### Hour ```ts Hour: "hour"; ``` **Source**: []() ##### Minute ```ts Minute: "minute"; ``` **Source**: []() ##### Month ```ts Month: "month"; ``` **Source**: []() ##### Second ```ts Second: "second"; ``` Not supported on iOS. **Source**: []() ##### TwoWeeks ```ts TwoWeeks: "twoWeeks"; ``` **Source**: []() ##### Week ```ts Week: "week"; ``` **Source**: []() ##### Year ```ts Year: "year"; ``` **Source**: *** []() ### Visibility #### Enumeration Members []() ##### Private ```ts Private: 0; ``` **Source**: []() ##### Public ```ts Public: 1; ``` **Source**: []() ##### Secret ```ts Secret: -1; ``` **Source**: ## Classes []() ### Schedule #### Constructors []() ##### new Schedule() ```ts new Schedule(): Schedule ``` ###### Returns [`Schedule`](/reference/javascript/notification/#schedule) #### Properties | Property | Type | Defined in | | -------------- | ----------------------- | ----------------------------------------------------------------------------------------------------------------- | | []()`at` | `undefined` \| `object` | **Source**: | | []()`every` | `undefined` \| `object` | **Source**: | | []()`interval` | `undefined` \| `object` | **Source**: | #### Methods []() ##### at() ```ts static at( date, repeating, allowWhileIdle): Schedule ``` ###### Parameters | Parameter | Type | Default value | | ---------------- | ----------------------------------------------------------------------------------------- | ------------- | | `date` | [`Date`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date) | `undefined` | | `repeating` | `boolean` | `false` | | `allowWhileIdle` | `boolean` | `false` | ###### Returns [`Schedule`](/reference/javascript/notification/#schedule) **Source**: []() ##### every() ```ts static every( kind, count, allowWhileIdle): Schedule ``` ###### Parameters | Parameter | Type | Default value | | ---------------- | -------------------------------------------------------------------- | ------------- | | `kind` | [`ScheduleEvery`](/reference/javascript/notification/#scheduleevery) | `undefined` | | `count` | `number` | `undefined` | | `allowWhileIdle` | `boolean` | `false` | ###### Returns [`Schedule`](/reference/javascript/notification/#schedule) **Source**: []() ##### interval() ```ts static interval(interval, allowWhileIdle): Schedule ``` ###### Parameters | Parameter | Type | Default value | | ---------------- | -------------------------------------------------------------------------- | ------------- | | `interval` | [`ScheduleInterval`](/reference/javascript/notification/#scheduleinterval) | `undefined` | | `allowWhileIdle` | `boolean` | `false` | ###### Returns [`Schedule`](/reference/javascript/notification/#schedule) **Source**: ## Interfaces []() ### Action #### Properties | Property | Type | Defined in | | ----------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------- | | []()`destructive?` | `boolean` | **Source**: | | []()`foreground?` | `boolean` | **Source**: | | []()`id` | `string` | **Source**: | | []()`input?` | `boolean` | **Source**: | | []()`inputButtonTitle?` | `string` | **Source**: | | []()`inputPlaceholder?` | `string` | **Source**: | | []()`requiresAuthentication?` | `boolean` | **Source**: | | []()`title` | `string` | **Source**: | *** []() ### ActionType #### Properties | Property | Type | Description | Defined in | | ------------------------------------ | --------------------------------------------------------- | ---------------------------------- | ----------------------------------------------------------------------------------------------------------------- | | []()`actions` | [`Action`](/reference/javascript/notification/#action)\[] | The list of associated actions | **Source**: | | []()`allowInCarPlay?` | `boolean` | - | **Source**: | | []()`customDismissAction?` | `boolean` | - | **Source**: | | []()`hiddenPreviewsBodyPlaceholder?` | `string` | - | **Source**: | | []()`hiddenPreviewsShowSubtitle?` | `boolean` | - | **Source**: | | []()`hiddenPreviewsShowTitle?` | `boolean` | - | **Source**: | | []()`id` | `string` | The identifier of this action type | **Source**: | *** []() ### ActiveNotification #### Properties | Property | Type | Defined in | | ------------------- | ---------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | | []()`actionTypeId?` | `string` | **Source**: | | []()`attachments` | [`Attachment`](/reference/javascript/notification/#attachment)\[] | **Source**: | | []()`body?` | `string` | **Source**: | | []()`data` | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)<`string`, `string`> | **Source**: | | []()`extra` | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)<`string`, `unknown`> | **Source**: | | []()`group?` | `string` | **Source**: | | []()`groupSummary` | `boolean` | **Source**: | | []()`id` | `number` | **Source**: | | []()`schedule?` | [`Schedule`](/reference/javascript/notification/#schedule) | **Source**: | | []()`sound?` | `string` | **Source**: | | []()`tag?` | `string` | **Source**: | | []()`title?` | `string` | **Source**: | *** []() ### Attachment Attachment of a notification. #### Properties | Property | Type | Description | Defined in | | --------- | -------- | --------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | | []()`id` | `string` | Attachment identifier. | **Source**: | | []()`url` | `string` | Attachment URL. Accepts the `asset` and `file` protocols. | **Source**: | *** []() ### Channel #### Properties | Property | Type | Defined in | | ------------------ | -------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | | []()`description?` | `string` | **Source**: | | []()`id` | `string` | **Source**: | | []()`importance?` | [`Importance`](/reference/javascript/notification/#importance) | **Source**: | | []()`lightColor?` | `string` | **Source**: | | []()`lights?` | `boolean` | **Source**: | | []()`name` | `string` | **Source**: | | []()`sound?` | `string` | **Source**: | | []()`vibration?` | `boolean` | **Source**: | | []()`visibility?` | [`Visibility`](/reference/javascript/notification/#visibility) | **Source**: | *** []() ### Options Options to send a notification. #### Since 2.0.0 #### Properties | Property | Type | Description | Defined in | | ------------------- | ---------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------- | | []()`actionTypeId?` | `string` | Defines an action type for this notification. | **Source**: | | []()`attachments?` | [`Attachment`](/reference/javascript/notification/#attachment)\[] | Notification attachments. | **Source**: | | []()`autoCancel?` | `boolean` | Automatically cancel the notification when the user clicks on it. | **Source**: | | []()`body?` | `string` | Optional notification body. | **Source**: | | []()`channelId?` | `string` | Identifier of the [Channel](/reference/javascript/notification/#channel) that deliveres this notification. If the channel does not exist, the notification won’t fire. Make sure the channel exists with listChannels and [createChannel](/reference/javascript/notification/#createchannel). | **Source**: | | []()`extra?` | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)<`string`, `unknown`> | Extra payload to store in the notification. | **Source**: | | []()`group?` | `string` | Identifier used to group multiple notifications. | **Source**: | | []()`groupSummary?` | `boolean` | Instructs the system that this notification is the summary of a group on Android. | **Source**: | | []()`icon?` | `string` | Notification icon. On Android the icon must be placed in the app’s `res/drawable` folder. | **Source**: | | []()`iconColor?` | `string` | Icon color on Android. | **Source**: | | []()`id?` | `number` | The notification identifier to reference this object later. Must be a 32-bit integer. | **Source**: | | []()`inboxLines?` | `string`\[] | List of lines to add to the notification. Changes the notification style to inbox. Cannot be used with `largeBody`. Only supports up to 5 lines. | **Source**: | | []()`largeBody?` | `string` | Multiline text. Changes the notification style to big text. Cannot be used with `inboxLines`. | **Source**: | | []()`largeIcon?` | `string` | Notification large icon (Android). The icon must be placed in the app’s `res/drawable` folder. | **Source**: | | []()`number?` | `number` | Sets the number of items this notification represents on Android. | **Source**: | | []()`ongoing?` | `boolean` | If true, the notification cannot be dismissed by the user on Android. An application service must manage the dismissal of the notification. It is typically used to indicate a background task that is pending (e.g. a file download) or the user is engaged with (e.g. playing music). | **Source**: | | []()`schedule?` | [`Schedule`](/reference/javascript/notification/#schedule) | Schedule this notification to fire on a later time or a fixed interval. | **Source**: | | []()`silent?` | `boolean` | Changes the notification presentation to be silent on iOS (no badge, no sound, not listed). | **Source**: | | []()`sound?` | `string` | The sound resource name or file path for the notification. ## Platform-specific behavior: - On macOS: use system sounds (e.g., “Ping”, “Blow”) or sound files in the app bundle - On Linux: use XDG theme sounds (e.g., “message-new-instant”) or file paths - On Windows: use file paths to sound files (.wav format) - On Mobile: use resource names | **Source**: | | []()`summary?` | `string` | Detail text for the notification with `largeBody`, `inboxLines` or `groupSummary`. | **Source**: | | []()`title` | `string` | Notification title. | **Source**: | | []()`visibility?` | [`Visibility`](/reference/javascript/notification/#visibility) | Notification visibility. | **Source**: | *** []() ### PendingNotification #### Properties | Property | Type | Defined in | | -------------- | ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | | []()`body?` | `string` | **Source**: | | []()`id` | `number` | **Source**: | | []()`schedule` | [`Schedule`](/reference/javascript/notification/#schedule) | **Source**: | | []()`title?` | `string` | **Source**: | *** []() ### ScheduleInterval #### Properties | Property | Type | Description | Defined in | | -------------- | -------- | ------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------- | | []()`day?` | `number` | - | **Source**: | | []()`hour?` | `number` | - | **Source**: | | []()`minute?` | `number` | - | **Source**: | | []()`month?` | `number` | - | **Source**: | | []()`second?` | `number` | - | **Source**: | | []()`weekday?` | `number` | 1 - Sunday 2 - Monday 3 - Tuesday 4 - Wednesday 5 - Thursday 6 - Friday 7 - Saturday | **Source**: | | []()`year?` | `number` | - | **Source**: | ## Type Aliases []() ### PermissionState ```ts type PermissionState: "granted" | "denied" | "prompt" | "prompt-with-rationale"; ``` **Source**: undefined ## Functions []() ### active() ```ts function active(): Promise ``` Retrieves the list of active notifications. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`ActiveNotification`](/reference/javascript/notification/#activenotification)\[]> A promise resolving to the list of active notifications. #### Example ```typescript import { active } from '@tauri-apps/plugin-notification'; const activeNotifications = await active(); ``` #### Since 2.0.0 **Source**: *** []() ### cancel() ```ts function cancel(notifications): Promise ``` Cancels the pending notifications with the given list of identifiers. #### Parameters | Parameter | Type | | --------------- | ----------- | | `notifications` | `number`\[] | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. #### Example ```typescript import { cancel } from '@tauri-apps/plugin-notification'; await cancel([-34234, 23432, 4311]); ``` #### Since 2.0.0 **Source**: *** []() ### cancelAll() ```ts function cancelAll(): Promise ``` Cancels all pending notifications. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. #### Example ```typescript import { cancelAll } from '@tauri-apps/plugin-notification'; await cancelAll(); ``` #### Since 2.0.0 **Source**: *** []() ### channels() ```ts function channels(): Promise ``` Retrieves the list of notification channels. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Channel`](/reference/javascript/notification/#channel)\[]> A promise resolving to the list of notification channels. #### Example ```typescript import { channels } from '@tauri-apps/plugin-notification'; const notificationChannels = await channels(); ``` #### Since 2.0.0 **Source**: *** []() ### createChannel() ```ts function createChannel(channel): Promise ``` Creates a notification channel. #### Parameters | Parameter | Type | | --------- | -------------------------------------------------------- | | `channel` | [`Channel`](/reference/javascript/notification/#channel) | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. #### Example ```typescript import { createChannel, Importance, Visibility } from '@tauri-apps/plugin-notification'; await createChannel({ id: 'new-messages', name: 'New Messages', lights: true, vibration: true, importance: Importance.Default, visibility: Visibility.Private }); ``` #### Since 2.0.0 **Source**: *** []() ### isPermissionGranted() ```ts function isPermissionGranted(): Promise ``` Checks if the permission to send notifications is granted. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> #### Example ```typescript import { isPermissionGranted } from '@tauri-apps/plugin-notification'; const permissionGranted = await isPermissionGranted(); ``` #### Since 2.0.0 **Source**: *** []() ### onAction() ```ts function onAction(cb): Promise ``` #### Parameters | Parameter | Type | | --------- | -------------------------- | | `cb` | (`notification`) => `void` | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`PluginListener`> **Source**: *** []() ### onNotificationReceived() ```ts function onNotificationReceived(cb): Promise ``` #### Parameters | Parameter | Type | | --------- | -------------------------- | | `cb` | (`notification`) => `void` | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`PluginListener`> **Source**: *** []() ### pending() ```ts function pending(): Promise ``` Retrieves the list of pending notifications. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`PendingNotification`](/reference/javascript/notification/#pendingnotification)\[]> A promise resolving to the list of pending notifications. #### Example ```typescript import { pending } from '@tauri-apps/plugin-notification'; const pendingNotifications = await pending(); ``` #### Since 2.0.0 **Source**: *** []() ### registerActionTypes() ```ts function registerActionTypes(types): Promise ``` Register actions that are performed when the user clicks on the notification. #### Parameters | Parameter | Type | | --------- | ----------------------------------------------------------------- | | `types` | [`ActionType`](/reference/javascript/notification/#actiontype)\[] | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. #### Example ```typescript import { registerActionTypes } from '@tauri-apps/plugin-notification'; await registerActionTypes([{ id: 'tauri', actions: [{ id: 'my-action', title: 'Settings' }] }]) ``` #### Since 2.0.0 **Source**: *** []() ### removeActive() ```ts function removeActive(notifications): Promise ``` Removes the active notifications with the given list of identifiers. #### Parameters | Parameter | Type | | --------------- | ----------- | | `notifications` | `object`\[] | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. #### Example ```typescript import { cancel } from '@tauri-apps/plugin-notification'; await cancel([-34234, 23432, 4311]) ``` #### Since 2.0.0 **Source**: *** []() ### removeAllActive() ```ts function removeAllActive(): Promise ``` Removes all active notifications. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. #### Example ```typescript import { removeAllActive } from '@tauri-apps/plugin-notification'; await removeAllActive() ``` #### Since 2.0.0 **Source**: *** []() ### removeChannel() ```ts function removeChannel(id): Promise ``` Removes the channel with the given identifier. #### Parameters | Parameter | Type | | --------- | -------- | | `id` | `string` | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. #### Example ```typescript import { removeChannel } from '@tauri-apps/plugin-notification'; await removeChannel(); ``` #### Since 2.0.0 **Source**: *** []() ### requestPermission() ```ts function requestPermission(): Promise ``` Requests the permission to send notifications. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`NotificationPermission`> A promise resolving to whether the user granted the permission or not. #### Example ```typescript import { isPermissionGranted, requestPermission } from '@tauri-apps/plugin-notification'; let permissionGranted = await isPermissionGranted(); if (!permissionGranted) { const permission = await requestPermission(); permissionGranted = permission === 'granted'; } ``` #### Since 2.0.0 **Source**: *** []() ### sendNotification() ```ts function sendNotification(options): void ``` Sends a notification to the user. #### Parameters | Parameter | Type | | --------- | -------------------------------------------------------------------- | | `options` | `string` \| [`Options`](/reference/javascript/notification/#options) | #### Returns `void` #### Example ```typescript import { isPermissionGranted, requestPermission, sendNotification } from '@tauri-apps/plugin-notification'; let permissionGranted = await isPermissionGranted(); if (!permissionGranted) { const permission = await requestPermission(); permissionGranted = permission === 'granted'; } if (permissionGranted) { sendNotification('Tauri is awesome!'); sendNotification({ title: 'TAURI', body: 'Tauri is awesome!' }); } ``` #### Since 2.0.0 **Source**: # @tauri-apps/plugin-opener Open files and URLs using their default application. ## Security This API has a scope configuration that forces you to restrict the files and urls to be opened. ### Restricting access to the open | `open` API On the configuration object, `open: true` means that the open API can be used with any URL, as the argument is validated with the `^((mailto:\w+)|(tel:\w+)|(https?://\w+)).+` regex. You can change that regex by changing the boolean value to a string, e.g. `open: ^https://github.com/`. ## Functions []() ### openPath() ```ts function openPath(path, openWith?): Promise ``` Opens a path with the system’s default app, or the one specified with openWith. #### Parameters | Parameter | Type | Description | | ----------- | -------- | ------------------------------------------------------------------------------------------------------------------------ | | `path` | `string` | The path to open. | | `openWith`? | `string` | The app to open the path with. If not specified, defaults to the system default application for the specified path type. | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> #### Example ```typescript import { openPath } from '@tauri-apps/plugin-opener'; // opens a file using the default program: await openPath('/path/to/file'); // opens a file using `vlc` command on Windows. await openPath('C:/path/to/file', 'vlc'); ``` #### Since 2.0.0 **Source**: *** []() ### openUrl() ```ts function openUrl(url, openWith?): Promise ``` Opens a url with the system’s default app, or the one specified with openWith. #### Parameters | Parameter | Type | Description | | ----------- | ------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `url` | `string` \| [`URL`](https://developer.mozilla.org/docs/Web/API/URL) | The URL to open. | | `openWith`? | `string` | The app to open the URL with. If not specified, defaults to the system default application for the specified url type. On mobile, `openWith` can be provided as `inAppBrowser` to open the URL in an in-app browser. Otherwise, it will open the URL in the system default browser. | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> #### Example ```typescript import { openUrl } from '@tauri-apps/plugin-opener'; // opens the given URL on the default browser: await openUrl('https://github.com/tauri-apps/tauri'); // opens the given URL using `firefox`: await openUrl('https://github.com/tauri-apps/tauri', 'firefox'); ``` #### Since 2.0.0 **Source**: *** []() ### revealItemInDir() ```ts function revealItemInDir(path): Promise ``` Reveal a path with the system’s default explorer. Platform-specific: * **Android / iOS:** Unsupported. #### Parameters | Parameter | Type | Description | | --------- | ----------------------- | ------------------- | | `path` | `string` \| `string`\[] | The path to reveal. | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> #### Example ```typescript import { revealItemInDir } from '@tauri-apps/plugin-opener'; await revealItemInDir('/path/to/file'); await revealItemInDir([ '/path/to/file', '/path/to/another/file' ]); ``` #### Since 2.0.0 **Source**: # @tauri-apps/plugin-os Provides operating system-related utility methods and properties. ## Type Aliases []() ### Arch ```ts type Arch: | "x86" | "x86_64" | "arm" | "aarch64" | "mips" | "mips64" | "powerpc" | "powerpc64" | "riscv64" | "s390x" | "sparc64"; ``` **Source**: *** []() ### Family ```ts type Family: "unix" | "windows"; ``` **Source**: *** []() ### OsType ```ts type OsType: | "linux" | "windows" | "macos" | "ios" | "android"; ``` **Source**: *** []() ### Platform ```ts type Platform: | "linux" | "macos" | "ios" | "freebsd" | "dragonfly" | "netbsd" | "openbsd" | "solaris" | "android" | "windows"; ``` **Source**: ## Functions []() ### arch() ```ts function arch(): Arch ``` Returns the current operating system architecture. Possible values are `'x86'`, `'x86_64'`, `'arm'`, `'aarch64'`, `'mips'`, `'mips64'`, `'powerpc'`, `'powerpc64'`, `'riscv64'`, `'s390x'`, `'sparc64'`. #### Returns [`Arch`](/reference/javascript/os/#arch) #### Example ```typescript import { arch } from '@tauri-apps/plugin-os'; const archName = arch(); ``` #### Since 2.0.0 **Source**: *** []() ### eol() ```ts function eol(): string ``` Returns the operating system-specific end-of-line marker. * `\n` on POSIX * `\r\n` on Windows #### Returns `string` #### Since 2.0.0 **Source**: *** []() ### exeExtension() ```ts function exeExtension(): string ``` Returns the file extension, if any, used for executable binaries on this platform. Possible values are `'exe'` and `''` (empty string). #### Returns `string` #### Example ```typescript import { exeExtension } from '@tauri-apps/plugin-os'; const exeExt = exeExtension(); ``` #### Since 2.0.0 **Source**: *** []() ### family() ```ts function family(): Family ``` Returns the current operating system family. Possible values are `'unix'`, `'windows'`. #### Returns [`Family`](/reference/javascript/os/#family) #### Example ```typescript import { family } from '@tauri-apps/plugin-os'; const family = family(); ``` #### Since 2.0.0 **Source**: *** []() ### hostname() ```ts function hostname(): Promise ``` Returns the host name of the operating system. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string` | `null`> #### Example ```typescript import { hostname } from '@tauri-apps/plugin-os'; const hostname = await hostname(); ``` **Source**: *** []() ### locale() ```ts function locale(): Promise ``` Returns a String with a `BCP-47` language tag inside. If the locale couldn’t be obtained, `null` is returned instead. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string` | `null`> #### Example ```typescript import { locale } from '@tauri-apps/plugin-os'; const locale = await locale(); if (locale) { // use the locale string here } ``` #### Since 2.0.0 **Source**: *** []() ### platform() ```ts function 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'` #### Returns [`Platform`](/reference/javascript/os/#platform) #### Example ```typescript import { platform } from '@tauri-apps/plugin-os'; const platformName = platform(); ``` #### Since 2.0.0 **Source**: *** []() ### type() ```ts function type(): OsType ``` Returns the current operating system type. Returns `'linux'` on Linux, `'macos'` on macOS, `'windows'` on Windows, `'ios'` on iOS and `'android'` on Android. #### Returns [`OsType`](/reference/javascript/os/#ostype) #### Example ```typescript import { type } from '@tauri-apps/plugin-os'; const osType = type(); ``` #### Since 2.0.0 **Source**: *** []() ### version() ```ts function version(): string ``` Returns the current operating system version. #### Returns `string` #### Example ```typescript import { version } from '@tauri-apps/plugin-os'; const osVersion = version(); ``` #### Since 2.0.0 **Source**: # @tauri-apps/plugin-positioner ## Enumerations []() ### Position Well known window positions. #### Enumeration Members []() ##### BottomCenter ```ts BottomCenter: 5; ``` **Source**: []() ##### BottomLeft ```ts BottomLeft: 2; ``` **Source**: []() ##### BottomRight ```ts BottomRight: 3; ``` **Source**: []() ##### Center ```ts Center: 8; ``` **Source**: []() ##### LeftCenter ```ts LeftCenter: 6; ``` **Source**: []() ##### RightCenter ```ts RightCenter: 7; ``` **Source**: []() ##### TopCenter ```ts TopCenter: 4; ``` **Source**: []() ##### TopLeft ```ts TopLeft: 0; ``` **Source**: []() ##### TopRight ```ts TopRight: 1; ``` **Source**: []() ##### TrayBottomCenter ```ts TrayBottomCenter: 14; ``` **Source**: []() ##### TrayBottomLeft ```ts TrayBottomLeft: 10; ``` **Source**: []() ##### TrayBottomRight ```ts TrayBottomRight: 12; ``` **Source**: []() ##### TrayCenter ```ts TrayCenter: 13; ``` **Source**: []() ##### TrayLeft ```ts TrayLeft: 9; ``` **Source**: []() ##### TrayRight ```ts TrayRight: 11; ``` **Source**: ## Functions []() ### handleIconState() ```ts function handleIconState(event): Promise ``` #### Parameters | Parameter | Type | | --------- | --------------- | | `event` | `TrayIconEvent` | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: *** []() ### moveWindow() ```ts function moveWindow(to): Promise ``` Moves the `Window` to the given [Position](/reference/javascript/positioner/#position) using `WindowExt.move_window()` All positions are relative to the **current** screen. #### Parameters | Parameter | Type | Description | | --------- | -------------------------------------------------------- | ---------------------------------------------------------------------- | | `to` | [`Position`](/reference/javascript/positioner/#position) | The [Position](/reference/javascript/positioner/#position) to move to. | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: *** []() ### moveWindowConstrained() ```ts function moveWindowConstrained(to): Promise ``` Moves the `Window` to the given [Position](/reference/javascript/positioner/#position) using `WindowExt.move_window_constrained()` This move operation constrains the window to the screen dimensions in case of tray-icon positions. #### Parameters | Parameter | Type | Description | | --------- | -------------------------------------------------------- | ----------------------------------------------------------------------------- | | `to` | [`Position`](/reference/javascript/positioner/#position) | The (tray) [Position](/reference/javascript/positioner/#position) to move to. | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: # @tauri-apps/plugin-process Perform operations on the current process. ## Functions []() ### exit() ```ts function exit(code): Promise ``` Exits immediately with the given `exitCode`. #### Parameters | Parameter | Type | Default value | Description | | --------- | -------- | ------------- | --------------------- | | `code` | `number` | `0` | The exit code to use. | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. #### Example ```typescript import { exit } from '@tauri-apps/plugin-process'; await exit(1); ``` #### Since 2.0.0 **Source**: *** []() ### relaunch() ```ts function relaunch(): Promise ``` Exits the current instance of the app then relaunches it. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> A promise indicating the success or failure of the operation. #### Example ```typescript import { relaunch } from '@tauri-apps/plugin-process'; await relaunch(); ``` #### Since 2.0.0 **Source**: # @tauri-apps/plugin-sql ## Classes []() ### default **Database** The `Database` class serves as the primary interface for communicating with the rust side of the sql plugin. #### Constructors []() ##### new default() ```ts new default(path): default ``` ###### Parameters | Parameter | Type | | --------- | -------- | | `path` | `string` | ###### Returns [`default`](/reference/javascript/sql/#default) **Source**: #### Properties | Property | Type | Defined in | | ---------- | -------- | ------------------------------------------------------------------------------------------------------- | | []()`path` | `string` | **Source**: | #### Methods []() ##### close() ```ts close(db?): Promise ``` **close** Closes the database connection pool. ###### Parameters | Parameter | Type | Description | | --------- | -------- | -------------------------------------------------------------------------------------------------------------------------- | | `db`? | `string` | Optionally state the name of a database if you are managing more than one. Otherwise, all database pools will be in scope. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> ###### Example ```ts const success = await db.close() ``` **Source**: []() ##### execute() ```ts execute(query, bindValues?): Promise ``` **execute** Passes a SQL expression to the database for execution. ###### Parameters | Parameter | Type | | ------------- | ------------ | | `query` | `string` | | `bindValues`? | `unknown`\[] | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`QueryResult`](/reference/javascript/sql/#queryresult)> ###### Example ```ts // for sqlite & postgres // INSERT example const result = await db.execute( "INSERT into todos (id, title, status) VALUES ($1, $2, $3)", [ todos.id, todos.title, todos.status ] ); // UPDATE example const result = await db.execute( "UPDATE todos SET title = $1, completed = $2 WHERE id = $3", [ todos.title, todos.status, todos.id ] ); // for mysql // INSERT example const result = await db.execute( "INSERT into todos (id, title, status) VALUES (?, ?, ?)", [ todos.id, todos.title, todos.status ] ); // UPDATE example const result = await db.execute( "UPDATE todos SET title = ?, completed = ? WHERE id = ?", [ todos.title, todos.status, todos.id ] ); ``` **Source**: []() ##### select() ```ts select(query, bindValues?): Promise ``` **select** Passes in a SELECT query to the database for execution. ###### Type Parameters | Type Parameter | | -------------- | | `T` | ###### Parameters | Parameter | Type | | ------------- | ------------ | | `query` | `string` | | `bindValues`? | `unknown`\[] | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`T`> ###### Example ```ts // for sqlite & postgres const result = await db.select( "SELECT * from todos WHERE id = $1", [ id ] ); // for mysql const result = await db.select( "SELECT * from todos WHERE id = ?", [ id ] ); ``` **Source**: []() ##### get() ```ts static get(path): default ``` **get** A static initializer which synchronously returns an instance of the Database class while deferring the actual database connection until the first invocation or selection on the database. # Sqlite The path is relative to `tauri::path::BaseDirectory::App` and must start with `sqlite:`. ###### Parameters | Parameter | Type | | --------- | -------- | | `path` | `string` | ###### Returns [`default`](/reference/javascript/sql/#default) ###### Example ```ts const db = Database.get("sqlite:test.db"); ``` **Source**: []() ##### load() ```ts static load(path): Promise ``` **load** A static initializer which connects to the underlying database and returns a `Database` instance once a connection to the database is established. # Sqlite The path is relative to `tauri::path::BaseDirectory::App` and must start with `sqlite:`. ###### Parameters | Parameter | Type | | --------- | -------- | | `path` | `string` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`default`](/reference/javascript/sql/#default)> ###### Example ```ts const db = await Database.load("sqlite:test.db"); ``` **Source**: ## Interfaces []() ### QueryResult #### Properties | Property | Type | Description | Defined in | | ------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | | []()`lastInsertId?` | `number` | The last inserted `id`. This value is not set for Postgres databases. If the last inserted id is required on Postgres, the `select` function must be used, with a `RETURNING` clause (`INSERT INTO todos (title) VALUES ($1) RETURNING id`). | **Source**: | | []()`rowsAffected` | `number` | The number of rows affected by the query. | **Source**: | # @tauri-apps/plugin-store ## Classes []() ### LazyStore A lazy loaded key-value store persisted by the backend layer. #### Implements * `IStore` #### Constructors []() ##### new LazyStore() ```ts new LazyStore(path, options?): LazyStore ``` Note that the options are not applied if someone else already created the store ###### Parameters | Parameter | Type | Description | | ---------- | ----------------------------------------------------------- | ---------------------------------------- | | `path` | `string` | Path to save the store in `app_data_dir` | | `options`? | [`StoreOptions`](/reference/javascript/store/#storeoptions) | Store configuration options | ###### Returns [`LazyStore`](/reference/javascript/store/#lazystore) **Source**: #### Methods []() ##### clear() ```ts clear(): Promise ``` Clears the store, removing all key-value pairs. Note: To clear the storage and reset it to its `default` value, use [`reset`](/reference/javascript/store/#reset) instead. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Implementation of `IStore.clear` **Source**: []() ##### close() ```ts close(): Promise ``` Close the store and cleans up this resource from memory. **You should not call any method on this object anymore and should drop any reference to it.** ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Implementation of `IStore.close` **Source**: []() ##### delete() ```ts delete(key): Promise ``` Removes a key-value pair from the store. ###### Parameters | Parameter | Type | Description | | --------- | -------- | ----------- | | `key` | `string` | | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> ###### Implementation of `IStore.delete` **Source**: []() ##### entries() ```ts entries(): Promise<[string, T][]> ``` Returns a list of all entries in the store. ###### Type Parameters | Type Parameter | | -------------- | | `T` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<\[`string`, `T`]\[]> ###### Implementation of `IStore.entries` **Source**: []() ##### get() ```ts get(key): Promise ``` Returns the value for the given `key` or `undefined` if the key does not exist. ###### Type Parameters | Type Parameter | | -------------- | | `T` | ###### Parameters | Parameter | Type | Description | | --------- | -------- | ----------- | | `key` | `string` | | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`undefined` | `T`> ###### Implementation of `IStore.get` **Source**: []() ##### has() ```ts has(key): Promise ``` Returns `true` if the given `key` exists in the store. ###### Parameters | Parameter | Type | Description | | --------- | -------- | ----------- | | `key` | `string` | | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> ###### Implementation of `IStore.has` **Source**: []() ##### init() ```ts init(): Promise ``` Init/load the store if it’s not loaded already ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### keys() ```ts keys(): Promise ``` Returns a list of all keys in the store. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`\[]> ###### Implementation of `IStore.keys` **Source**: []() ##### length() ```ts length(): Promise ``` Returns the number of key-value pairs in the store. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`number`> ###### Implementation of `IStore.length` **Source**: []() ##### onChange() ```ts onChange(cb): Promise ``` Listen to changes on the store. ###### Type Parameters | Type Parameter | | -------------- | | `T` | ###### Parameters | Parameter | Type | Description | | --------- | -------------------------- | ----------- | | `cb` | (`key`, `value`) => `void` | | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`UnlistenFn`> A promise resolving to a function to unlisten to the event. ###### Since 2.0.0 ###### Implementation of `IStore.onChange` **Source**: []() ##### onKeyChange() ```ts onKeyChange(key, cb): Promise ``` Listen to changes on a store key. ###### Type Parameters | Type Parameter | | -------------- | | `T` | ###### Parameters | Parameter | Type | Description | | --------- | ------------------- | ----------- | | `key` | `string` | | | `cb` | (`value`) => `void` | | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`UnlistenFn`> A promise resolving to a function to unlisten to the event. ###### Since 2.0.0 ###### Implementation of `IStore.onKeyChange` **Source**: []() ##### reload() ```ts reload(options?): Promise ``` Attempts to load the on-disk state at the store’s `path` into memory. This method is useful if the on-disk state was edited by the user and you want to synchronize the changes. Note: * This method loads the data and merges it with the current store, this behavior will be changed to resetting to default first and then merging with the on-disk state in v3, to fully match the store with the on-disk state, set [`ignoreDefaults`](/reference/javascript/store/#reloadoptions) to `true` * This method does not emit change events. ###### Parameters | Parameter | Type | | ---------- | ------------------------------------------------------------- | | `options`? | [`ReloadOptions`](/reference/javascript/store/#reloadoptions) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Implementation of `IStore.reload` **Source**: []() ##### reset() ```ts reset(): Promise ``` Resets the store to its `default` value. If no default value has been set, this method behaves identical to [`clear`](/reference/javascript/store/#clear). ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Implementation of `IStore.reset` **Source**: []() ##### save() ```ts save(): Promise ``` Saves the store to disk at the store’s `path`. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Implementation of `IStore.save` **Source**: []() ##### set() ```ts set(key, value): Promise ``` Inserts a key-value pair into the store. ###### Parameters | Parameter | Type | Description | | --------- | --------- | ----------- | | `key` | `string` | | | `value` | `unknown` | | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Implementation of `IStore.set` **Source**: []() ##### values() ```ts values(): Promise ``` Returns a list of all values in the store. ###### Type Parameters | Type Parameter | | -------------- | | `T` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`T`\[]> ###### Implementation of `IStore.values` **Source**: *** []() ### Store A key-value store persisted by the backend layer. #### Extends * `Resource` #### Implements * `IStore` #### Accessors []() ##### rid ```ts get rid(): number ``` ###### Returns `number` ###### Inherited from `Resource.rid` **Source**: undefined #### Methods []() ##### clear() ```ts clear(): Promise ``` Clears the store, removing all key-value pairs. Note: To clear the storage and reset it to its `default` value, use [`reset`](/reference/javascript/store/#reset-1) instead. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Implementation of `IStore.clear` **Source**: []() ##### close() ```ts close(): Promise ``` Destroys and cleans up this resource from memory. **You should not call any method on this object anymore and should drop any reference to it.** ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Implementation of `IStore.close` ###### Inherited from `Resource.close` **Source**: undefined []() ##### delete() ```ts delete(key): Promise ``` Removes a key-value pair from the store. ###### Parameters | Parameter | Type | Description | | --------- | -------- | ----------- | | `key` | `string` | | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> ###### Implementation of `IStore.delete` **Source**: []() ##### entries() ```ts entries(): Promise<[string, T][]> ``` Returns a list of all entries in the store. ###### Type Parameters | Type Parameter | | -------------- | | `T` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<\[`string`, `T`]\[]> ###### Implementation of `IStore.entries` **Source**: []() ##### get() ```ts get(key): Promise ``` Returns the value for the given `key` or `undefined` if the key does not exist. ###### Type Parameters | Type Parameter | | -------------- | | `T` | ###### Parameters | Parameter | Type | Description | | --------- | -------- | ----------- | | `key` | `string` | | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`undefined` | `T`> ###### Implementation of `IStore.get` **Source**: []() ##### has() ```ts has(key): Promise ``` Returns `true` if the given `key` exists in the store. ###### Parameters | Parameter | Type | Description | | --------- | -------- | ----------- | | `key` | `string` | | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`boolean`> ###### Implementation of `IStore.has` **Source**: []() ##### keys() ```ts keys(): Promise ``` Returns a list of all keys in the store. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`\[]> ###### Implementation of `IStore.keys` **Source**: []() ##### length() ```ts length(): Promise ``` Returns the number of key-value pairs in the store. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`number`> ###### Implementation of `IStore.length` **Source**: []() ##### onChange() ```ts onChange(cb): Promise ``` Listen to changes on the store. ###### Type Parameters | Type Parameter | | -------------- | | `T` | ###### Parameters | Parameter | Type | Description | | --------- | -------------------------- | ----------- | | `cb` | (`key`, `value`) => `void` | | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`UnlistenFn`> A promise resolving to a function to unlisten to the event. ###### Since 2.0.0 ###### Implementation of `IStore.onChange` **Source**: []() ##### onKeyChange() ```ts onKeyChange(key, cb): Promise ``` Listen to changes on a store key. ###### Type Parameters | Type Parameter | | -------------- | | `T` | ###### Parameters | Parameter | Type | Description | | --------- | ------------------- | ----------- | | `key` | `string` | | | `cb` | (`value`) => `void` | | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`UnlistenFn`> A promise resolving to a function to unlisten to the event. ###### Since 2.0.0 ###### Implementation of `IStore.onKeyChange` **Source**: []() ##### reload() ```ts reload(options?): Promise ``` Attempts to load the on-disk state at the store’s `path` into memory. This method is useful if the on-disk state was edited by the user and you want to synchronize the changes. Note: * This method loads the data and merges it with the current store, this behavior will be changed to resetting to default first and then merging with the on-disk state in v3, to fully match the store with the on-disk state, set [`ignoreDefaults`](/reference/javascript/store/#reloadoptions) to `true` * This method does not emit change events. ###### Parameters | Parameter | Type | | ---------- | ------------------------------------------------------------- | | `options`? | [`ReloadOptions`](/reference/javascript/store/#reloadoptions) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Implementation of `IStore.reload` **Source**: []() ##### reset() ```ts reset(): Promise ``` Resets the store to its `default` value. If no default value has been set, this method behaves identical to [`clear`](/reference/javascript/store/#clear-1). ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Implementation of `IStore.reset` **Source**: []() ##### save() ```ts save(): Promise ``` Saves the store to disk at the store’s `path`. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Implementation of `IStore.save` **Source**: []() ##### set() ```ts set(key, value): Promise ``` Inserts a key-value pair into the store. ###### Parameters | Parameter | Type | Description | | --------- | --------- | ----------- | | `key` | `string` | | | `value` | `unknown` | | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Implementation of `IStore.set` **Source**: []() ##### values() ```ts values(): Promise ``` Returns a list of all values in the store. ###### Type Parameters | Type Parameter | | -------------- | | `T` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`T`\[]> ###### Implementation of `IStore.values` **Source**: []() ##### get() ```ts static get(path): Promise ``` Gets an already loaded store. If the store is not loaded, returns `null`. In this case you must [load](/reference/javascript/store/#load) it. This function is more useful when you already know the store is loaded and just need to access its instance. Prefer [Store.load](/reference/javascript/store/#load) otherwise. ###### Parameters | Parameter | Type | Description | | --------- | -------- | ------------------ | | `path` | `string` | Path of the store. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`null` | [`Store`](/reference/javascript/store/#store)> ###### Example ```typescript import { Store } from '@tauri-apps/api/store'; let store = await Store.get('store.json'); if (!store) { store = await Store.load('store.json'); } ``` **Source**: []() ##### load() ```ts static load(path, options?): Promise ``` Create a new Store or load the existing store with the path. ###### Parameters | Parameter | Type | Description | | ---------- | ----------------------------------------------------------- | ---------------------------------------- | | `path` | `string` | Path to save the store in `app_data_dir` | | `options`? | [`StoreOptions`](/reference/javascript/store/#storeoptions) | Store configuration options | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Store`](/reference/javascript/store/#store)> ###### Example ```typescript import { Store } from '@tauri-apps/api/store'; const store = await Store.load('store.json'); ``` **Source**: ## Type Aliases []() ### ReloadOptions ```ts type ReloadOptions: object; ``` Options to IStore.reload a IStore #### Type declaration | Name | Type | Description | Defined in | | ---------------- | --------- | ------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------- | | `ignoreDefaults` | `boolean` | To fully match the store with the on-disk state, ignoring defaults | **Source**: | **Source**: *** []() ### StoreOptions ```ts type StoreOptions: object; ``` Options to create a store #### Type declaration | Name | Type | Description | Defined in | | ------------------- | --------------------- | ---------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | | `autoSave` | `boolean` \| `number` | Auto save on modification with debounce duration in milliseconds, it’s 100ms by default, pass in `false` to disable it | **Source**: | | `createNew` | `boolean` | Force create a new store with default values even if it already exists. | **Source**: | | `defaults` | `object` | Default value of the store | **Source**: | | `deserializeFnName` | `string` | Name of a deserialize function registered in the rust side plugin builder | **Source**: | | `overrideDefaults` | `boolean` | When creating the store, override the store with the on-disk state if it exists, ignoring defaults | **Source**: | | `serializeFnName` | `string` | Name of a serialize function registered in the rust side plugin builder | **Source**: | **Source**: ## Functions []() ### getStore() ```ts function getStore(path): Promise ``` Gets an already loaded store. If the store is not loaded, returns `null`. In this case you must [load](/reference/javascript/store/#load) it. This function is more useful when you already know the store is loaded and just need to access its instance. Prefer [Store.load](/reference/javascript/store/#load) otherwise. #### Parameters | Parameter | Type | Description | | --------- | -------- | ------------------ | | `path` | `string` | Path of the store. | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Store`](/reference/javascript/store/#store) | `null`> #### Example ```typescript import { getStore } from '@tauri-apps/api/store'; const store = await getStore('store.json'); ``` **Source**: *** []() ### load() ```ts function load(path, options?): Promise ``` Create a new Store or load the existing store with the path. #### Parameters | Parameter | Type | Description | | ---------- | ----------------------------------------------------------- | ---------------------------------------- | | `path` | `string` | Path to save the store in `app_data_dir` | | `options`? | [`StoreOptions`](/reference/javascript/store/#storeoptions) | Store configuration options | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Store`](/reference/javascript/store/#store)> #### Example ```typescript import { Store } from '@tauri-apps/api/store'; const store = await Store.load('store.json'); ``` **Source**: # @tauri-apps/plugin-stronghold ## Classes []() ### Client #### Constructors []() ##### new Client() ```ts new Client(path, name): Client ``` ###### Parameters | Parameter | Type | | --------- | ------------------------------------------------------------ | | `path` | `string` | | `name` | [`ClientPath`](/reference/javascript/stronghold/#clientpath) | ###### Returns [`Client`](/reference/javascript/stronghold/#client) **Source**: #### Properties | Property | Type | Defined in | | ---------- | ------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------- | | []()`name` | [`ClientPath`](/reference/javascript/stronghold/#clientpath) | **Source**: | | []()`path` | `string` | **Source**: | #### Methods []() ##### getStore() ```ts getStore(): Store ``` ###### Returns [`Store`](/reference/javascript/stronghold/#store) **Source**: []() ##### getVault() ```ts getVault(name): Vault ``` Get a vault by name. ###### Parameters | Parameter | Type | Description | | --------- | ---------------------------------------------------------- | ----------- | | `name` | [`VaultPath`](/reference/javascript/stronghold/#vaultpath) | | ###### Returns [`Vault`](/reference/javascript/stronghold/#vault) **Source**: *** []() ### Location #### Constructors []() ##### new Location() ```ts new Location(type, payload): Location ``` ###### Parameters | Parameter | Type | | --------- | ---------------------------------------------------------------------------------------------------------------- | | `type` | `string` | | `payload` | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)<`string`, `unknown`> | ###### Returns [`Location`](/reference/javascript/stronghold/#location) **Source**: #### Properties | Property | Type | Defined in | | ------------- | ---------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | | []()`payload` | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)<`string`, `unknown`> | **Source**: | | []()`type` | `string` | **Source**: | #### Methods []() ##### counter() ```ts static counter(vault, counter): Location ``` ###### Parameters | Parameter | Type | | --------- | ---------------------------------------------------------- | | `vault` | [`VaultPath`](/reference/javascript/stronghold/#vaultpath) | | `counter` | `number` | ###### Returns [`Location`](/reference/javascript/stronghold/#location) **Source**: []() ##### generic() ```ts static generic(vault, record): Location ``` ###### Parameters | Parameter | Type | | --------- | ------------------------------------------------------------ | | `vault` | [`VaultPath`](/reference/javascript/stronghold/#vaultpath) | | `record` | [`RecordPath`](/reference/javascript/stronghold/#recordpath) | ###### Returns [`Location`](/reference/javascript/stronghold/#location) **Source**: *** []() ### Store #### Constructors []() ##### new Store() ```ts new Store(path, client): Store ``` ###### Parameters | Parameter | Type | | --------- | ------------------------------------------------------------ | | `path` | `string` | | `client` | [`ClientPath`](/reference/javascript/stronghold/#clientpath) | ###### Returns [`Store`](/reference/javascript/stronghold/#store) **Source**: #### Properties | Property | Type | Defined in | | ------------ | ------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------- | | []()`client` | [`ClientPath`](/reference/javascript/stronghold/#clientpath) | **Source**: | | []()`path` | `string` | **Source**: | #### Methods []() ##### get() ```ts get(key): Promise ``` ###### Parameters | Parameter | Type | | --------- | -------------------------------------------------------- | | `key` | [`StoreKey`](/reference/javascript/stronghold/#storekey) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`null` | [`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)> **Source**: []() ##### insert() ```ts insert( key, value, lifetime?): Promise ``` ###### Parameters | Parameter | Type | | ----------- | -------------------------------------------------------- | | `key` | [`StoreKey`](/reference/javascript/stronghold/#storekey) | | `value` | `number`\[] | | `lifetime`? | [`Duration`](/reference/javascript/stronghold/#duration) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### remove() ```ts remove(key): Promise ``` ###### Parameters | Parameter | Type | | --------- | -------------------------------------------------------- | | `key` | [`StoreKey`](/reference/javascript/stronghold/#storekey) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`null` | [`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)> **Source**: *** []() ### Stronghold A representation of an access to a stronghold. #### Properties | Property | Type | Defined in | | ---------- | -------- | --------------------------------------------------------------------------------------------------------------- | | []()`path` | `string` | **Source**: | #### Methods []() ##### createClient() ```ts createClient(client): Promise ``` ###### Parameters | Parameter | Type | | --------- | ------------------------------------------------------------ | | `client` | [`ClientPath`](/reference/javascript/stronghold/#clientpath) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Client`](/reference/javascript/stronghold/#client)> **Source**: []() ##### loadClient() ```ts loadClient(client): Promise ``` ###### Parameters | Parameter | Type | | --------- | ------------------------------------------------------------ | | `client` | [`ClientPath`](/reference/javascript/stronghold/#clientpath) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Client`](/reference/javascript/stronghold/#client)> **Source**: []() ##### save() ```ts save(): Promise ``` Persists the stronghold state to the snapshot. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### unload() ```ts unload(): Promise ``` Remove this instance from the cache. ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### load() ```ts static load(path, password): Promise ``` Load the snapshot if it exists (password must match), or start a fresh stronghold instance otherwise. ###### Parameters | Parameter | Type | Description | | ---------- | -------- | ----------- | | `path` | `string` | - | | `password` | `string` | | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Stronghold`](/reference/javascript/stronghold/#stronghold)> **Source**: *** []() ### Vault A key-value storage that allows create, update and delete operations. It does not allow reading the data, so one of the procedures must be used to manipulate the stored data, allowing secure storage of secrets. #### Extends * `ProcedureExecutor` #### Constructors []() ##### new Vault() ```ts new Vault( path, client, name): Vault ``` ###### Parameters | Parameter | Type | | --------- | ------------------------------------------------------------ | | `path` | `string` | | `client` | [`ClientPath`](/reference/javascript/stronghold/#clientpath) | | `name` | [`VaultPath`](/reference/javascript/stronghold/#vaultpath) | ###### Returns [`Vault`](/reference/javascript/stronghold/#vault) ###### Overrides `ProcedureExecutor.constructor` **Source**: #### Properties | Property | Type | Description | Inherited from | Defined in | | ------------------- | ---------------------------------------------------------------------------------------------------------------- | --------------- | --------------------------------- | --------------------------------------------------------------------------------------------------------------- | | []()`client` | [`ClientPath`](/reference/javascript/stronghold/#clientpath) | - | - | **Source**: | | []()`name` | [`VaultPath`](/reference/javascript/stronghold/#vaultpath) | The vault name. | - | **Source**: | | []()`path` | `string` | The vault path. | - | **Source**: | | []()`procedureArgs` | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)<`string`, `unknown`> | - | `ProcedureExecutor.procedureArgs` | **Source**: | #### Methods []() ##### deriveSLIP10() ```ts deriveSLIP10( chain, source, sourceLocation, outputLocation): Promise ``` Derive a SLIP10 private key using a seed or key. ###### Parameters | Parameter | Type | Description | | ---------------- | -------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | | `chain` | `number`\[] | The chain path. | | `source` | `"Seed"` \| `"Key"` | The source type, either ‘Seed’ or ‘Key’. | | `sourceLocation` | [`Location`](/reference/javascript/stronghold/#location) | The source location, must be the `outputLocation` of a previous call to `generateSLIP10Seed` or `deriveSLIP10`. | | `outputLocation` | [`Location`](/reference/javascript/stronghold/#location) | Location of the record where the private key will be stored. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)> ###### Inherited from `ProcedureExecutor.deriveSLIP10` **Source**: []() ##### generateBIP39() ```ts generateBIP39(outputLocation, passphrase?): Promise ``` Generate a BIP39 seed. ###### Parameters | Parameter | Type | Description | | ---------------- | -------------------------------------------------------- | --------------------------------------------------------------- | | `outputLocation` | [`Location`](/reference/javascript/stronghold/#location) | The location of the record where the BIP39 seed will be stored. | | `passphrase`? | `string` | The optional mnemonic passphrase. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)> ###### Inherited from `ProcedureExecutor.generateBIP39` **Source**: []() ##### generateSLIP10Seed() ```ts generateSLIP10Seed(outputLocation, sizeBytes?): Promise ``` Generate a SLIP10 seed for the given location. ###### Parameters | Parameter | Type | Description | | ---------------- | -------------------------------------------------------- | ----------------------------------------------------- | | `outputLocation` | [`Location`](/reference/javascript/stronghold/#location) | Location of the record where the seed will be stored. | | `sizeBytes`? | `number` | The size in bytes of the SLIP10 seed. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)> ###### Inherited from `ProcedureExecutor.generateSLIP10Seed` **Source**: []() ##### getEd25519PublicKey() ```ts getEd25519PublicKey(privateKeyLocation): Promise ``` Gets the Ed25519 public key of a SLIP10 private key. ###### Parameters | Parameter | Type | Description | | -------------------- | -------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | | `privateKeyLocation` | [`Location`](/reference/javascript/stronghold/#location) | The location of the private key. Must be the `outputLocation` of a previous call to `deriveSLIP10`. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)> A promise resolving to the public key hex string. ###### Since 2.0.0 ###### Inherited from `ProcedureExecutor.getEd25519PublicKey` **Source**: []() ##### insert() ```ts insert(recordPath, secret): Promise ``` Insert a record to this vault. ###### Parameters | Parameter | Type | | ------------ | ------------------------------------------------------------ | | `recordPath` | [`RecordPath`](/reference/javascript/stronghold/#recordpath) | | `secret` | `number`\[] | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### recoverBIP39() ```ts recoverBIP39( mnemonic, outputLocation, passphrase?): Promise ``` Store a BIP39 mnemonic. ###### Parameters | Parameter | Type | Description | | ---------------- | -------------------------------------------------------- | ------------------------------------------------------------------- | | `mnemonic` | `string` | The mnemonic string. | | `outputLocation` | [`Location`](/reference/javascript/stronghold/#location) | The location of the record where the BIP39 mnemonic will be stored. | | `passphrase`? | `string` | The optional mnemonic passphrase. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)> ###### Inherited from `ProcedureExecutor.recoverBIP39` **Source**: []() ##### remove() ```ts remove(location): Promise ``` Remove a record from the vault. ###### Parameters | Parameter | Type | Description | | ---------- | -------------------------------------------------------- | -------------------- | | `location` | [`Location`](/reference/javascript/stronghold/#location) | The record location. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### signEd25519() ```ts signEd25519(privateKeyLocation, msg): Promise ``` Creates a Ed25519 signature from a private key. ###### Parameters | Parameter | Type | Description | | -------------------- | -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | | `privateKeyLocation` | [`Location`](/reference/javascript/stronghold/#location) | The location of the record where the private key is stored. Must be the `outputLocation` of a previous call to `deriveSLIP10`. | | `msg` | `string` | The message to sign. | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)> A promise resolving to the signature hex string. ###### Since 2.0.0 ###### Inherited from `ProcedureExecutor.signEd25519` **Source**: ## Interfaces []() ### AddressInfo #### Properties | Property | Type | Defined in | | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | | []()`peers` | [`Map`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map)<`string`, [`PeerAddress`](/reference/javascript/stronghold/#peeraddress)> | **Source**: | | []()`relays` | `string`\[] | **Source**: | *** []() ### ClientAccess #### Properties | Property | Type | Defined in | | --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | | []()`cloneVaultDefault?` | `boolean` | **Source**: | | []()`cloneVaultExceptions?` | [`Map`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map)<[`VaultPath`](/reference/javascript/stronghold/#vaultpath), `boolean`> | **Source**: | | []()`readStore?` | `boolean` | **Source**: | | []()`useVaultDefault?` | `boolean` | **Source**: | | []()`useVaultExceptions?` | [`Map`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map)<[`VaultPath`](/reference/javascript/stronghold/#vaultpath), `boolean`> | **Source**: | | []()`writeStore?` | `boolean` | **Source**: | | []()`writeVaultDefault?` | `boolean` | **Source**: | | []()`writeVaultExceptions?` | [`Map`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map)<[`VaultPath`](/reference/javascript/stronghold/#vaultpath), `boolean`> | **Source**: | *** []() ### ConnectionLimits #### Properties | Property | Type | Defined in | | ----------------------------- | -------- | -------------------------------------------------------------------------------------------------------------- | | []()`maxEstablishedIncoming?` | `number` | **Source**: | | []()`maxEstablishedOutgoing?` | `number` | **Source**: | | []()`maxEstablishedPerPeer?` | `number` | **Source**: | | []()`maxEstablishedTotal?` | `number` | **Source**: | | []()`maxPendingIncoming?` | `number` | **Source**: | | []()`maxPendingOutgoing?` | `number` | **Source**: | *** []() ### Duration A duration definition. #### Properties | Property | Type | Description | Defined in | | ----------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | | []()`nanos` | `number` | The fractional part of this Duration, in nanoseconds. Must be greater or equal to 0 and smaller than 1e+9 (the max number of nanoseoncds in a second) | **Source**: | | []()`secs` | `number` | The number of whole seconds contained by this Duration. | **Source**: | *** []() ### NetworkConfig #### Properties | Property | Type | Defined in | | ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | | []()`addresses?` | [`AddressInfo`](/reference/javascript/stronghold/#addressinfo) | **Source**: | | []()`connectionTimeout?` | [`Duration`](/reference/javascript/stronghold/#duration) | **Source**: | | []()`connectionsLimit?` | [`ConnectionLimits`](/reference/javascript/stronghold/#connectionlimits) | **Source**: | | []()`enableMdns?` | `boolean` | **Source**: | | []()`enableRelay?` | `boolean` | **Source**: | | []()`peerPermissions?` | [`Map`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map)<`string`, [`Permissions`](/reference/javascript/stronghold/#permissions)> | **Source**: | | []()`permissionsDefault?` | [`Permissions`](/reference/javascript/stronghold/#permissions) | **Source**: | | []()`requestTimeout?` | [`Duration`](/reference/javascript/stronghold/#duration) | **Source**: | *** []() ### PeerAddress #### Properties | Property | Type | Defined in | | ------------------------ | ----------- | -------------------------------------------------------------------------------------------------------------- | | []()`known` | `string`\[] | **Source**: | | []()`use_relay_fallback` | `boolean` | **Source**: | *** []() ### Permissions #### Properties | Property | Type | Defined in | | ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | | []()`default?` | [`ClientAccess`](/reference/javascript/stronghold/#clientaccess) | **Source**: | | []()`exceptions?` | [`Map`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map)<[`VaultPath`](/reference/javascript/stronghold/#vaultpath), [`ClientAccess`](/reference/javascript/stronghold/#clientaccess)> | **Source**: | ## Type Aliases []() ### ClientPath ```ts type ClientPath: string | Iterable | ArrayLike | ArrayBuffer; ``` **Source**: *** []() ### RecordPath ```ts type RecordPath: string | Iterable | ArrayLike | ArrayBuffer; ``` **Source**: *** []() ### StoreKey ```ts type StoreKey: string | Iterable | ArrayLike | ArrayBuffer; ``` **Source**: *** []() ### VaultPath ```ts type VaultPath: string | Iterable | ArrayLike | ArrayBuffer; ``` **Source**: # @tauri-apps/plugin-updater ## Classes []() ### Update #### Extends * `Resource` #### Constructors []() ##### new Update() ```ts new Update(metadata): Update ``` ###### Parameters | Parameter | Type | | ---------- | ---------------- | | `metadata` | `UpdateMetadata` | ###### Returns [`Update`](/reference/javascript/updater/#update) ###### Overrides `Resource.constructor` **Source**: #### Properties | Property | Type | Description | Defined in | | -------------------- | ---------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------- | | []()~~`available`~~ | `boolean` | **Deprecated** This is always true, check if the return value is `null` instead when using [`check`](/reference/javascript/updater/#check) | **Source**: | | []()`body?` | `string` | - | **Source**: | | []()`currentVersion` | `string` | - | **Source**: | | []()`date?` | `string` | - | **Source**: | | []()`rawJson` | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)<`string`, `unknown`> | - | **Source**: | | []()`version` | `string` | - | **Source**: | #### Accessors []() ##### rid ```ts get rid(): number ``` ###### Returns `number` ###### Inherited from `Resource.rid` **Source**: undefined #### Methods []() ##### close() ```ts close(): Promise ``` Destroys and cleans up this resource from memory. **You should not call any method on this object anymore and should drop any reference to it.** ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> ###### Overrides `Resource.close` **Source**: []() ##### download() ```ts download(onEvent?, options?): Promise ``` Download the updater package. Call [`install`](/reference/javascript/updater/#install) later to install it ###### Parameters | Parameter | Type | | ---------- | ------------------------------------------------------------------- | | `onEvent`? | (`progress`) => `void` | | `options`? | [`DownloadOptions`](/reference/javascript/updater/#downloadoptions) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### downloadAndInstall() ```ts downloadAndInstall(onEvent?, options?): Promise ``` Downloads the updater package and installs it ## Platform-specific: * **Windows:** This function exits the app after launching the updater installer successfully * **macOS / Linux:** You need to relaunch the app to run the newly install version ###### Parameters | Parameter | Type | | ---------- | -------------------------------------------------------------------------------------- | | `onEvent`? | (`progress`) => `void` | | `options`? | [`DownloadOptions`](/reference/javascript/updater/#downloadoptions) & `InstallOptions` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### install() ```ts install(options?): Promise ``` Install downloaded updater package. Must be called after [`download`](/reference/javascript/updater/#download). ## Platform-specific: * **Windows:** This function exits the app after launching the updater installer successfully * **macOS / Linux:** You need to relaunch the app to run the newly install version ###### Parameters | Parameter | Type | | ---------- | ---------------- | | `options`? | `InstallOptions` | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: ## Interfaces []() ### CheckOptions Options used when checking for updates #### Properties | Property | Type | Description | Defined in | | ---------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | | []()`allowDowngrades?` | `boolean` | Allow downgrades to previous versions by not checking if the current version is greater than the available version. | **Source**: | | []()`headers?` | `HeadersInit` | Request headers | **Source**: | | []()`proxy?` | `string` | A proxy url to be used when checking and downloading updates. | **Source**: | | []()`target?` | `string` | Target identifier for the running application. This is sent to the backend. | **Source**: | | []()`timeout?` | `number` | Timeout in milliseconds | **Source**: | *** []() ### DownloadOptions Options used when downloading an update #### Properties | Property | Type | Description | Defined in | | -------------- | ------------- | ----------------------- | ----------------------------------------------------------------------------------------------------------- | | []()`headers?` | `HeadersInit` | Request headers | **Source**: | | []()`timeout?` | `number` | Timeout in milliseconds | **Source**: | ## Type Aliases []() ### DownloadEvent ```ts type DownloadEvent: object | object | object; ``` Updater download event **Source**: ## Functions []() ### check() ```ts function check(options?): Promise ``` Check for updates, resolves to `null` if no updates are available #### Parameters | Parameter | Type | | ---------- | ------------------------------------------------------------- | | `options`? | [`CheckOptions`](/reference/javascript/updater/#checkoptions) | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`Update`](/reference/javascript/updater/#update) | `null`> **Source**: # @tauri-apps/plugin-upload ## Enumerations []() ### HttpMethod #### Enumeration Members []() ##### Patch ```ts Patch: "PATCH"; ``` **Source**: []() ##### Post ```ts Post: "POST"; ``` **Source**: []() ##### Put ```ts Put: "PUT"; ``` **Source**: ## Functions []() ### download() ```ts function download( url, filePath, progressHandler?, headers?, body?): Promise ``` #### Parameters | Parameter | Type | | ------------------ | ----------------------------------------------------------------------------------------------------------- | | `url` | `string` | | `filePath` | `string` | | `progressHandler`? | `ProgressHandler` | | `headers`? | [`Map`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map)<`string`, `string`> | | `body`? | `string` | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: *** []() ### upload() ```ts function upload( url, filePath, progressHandler?, headers?, method?): Promise ``` #### Parameters | Parameter | Type | | ------------------ | ----------------------------------------------------------------------------------------------------------- | | `url` | `string` | | `filePath` | `string` | | `progressHandler`? | `ProgressHandler` | | `headers`? | [`Map`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map)<`string`, `string`> | | `method`? | [`HttpMethod`](/reference/javascript/upload/#httpmethod) | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> **Source**: # @tauri-apps/plugin-websocket ## Classes []() ### default #### Constructors []() ##### new default() ```ts new default(id, listeners): default ``` ###### Parameters | Parameter | Type | | ----------- | ---------------------------------------------------------------------------------------------------------- | | `id` | `number` | | `listeners` | [`Set`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set)<(`arg`) => `void`> | ###### Returns [`default`](/reference/javascript/websocket/#default) **Source**: #### Properties | Property | Type | Defined in | | -------- | -------- | ------------------------------------------------------------------------------------------------------------- | | []()`id` | `number` | **Source**: | #### Methods []() ##### addListener() ```ts addListener(cb): () => void ``` ###### Parameters | Parameter | Type | | --------- | ----------------- | | `cb` | (`arg`) => `void` | ###### Returns `Function` ###### Returns `void` **Source**: []() ##### disconnect() ```ts disconnect(): Promise ``` ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### send() ```ts send(message): Promise ``` ###### Parameters | Parameter | Type | | --------- | -------------------------------------------------------------------------------- | | `message` | `string` \| `number`\[] \| [`Message`](/reference/javascript/websocket/#message) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: []() ##### connect() ```ts static connect(url, config?): Promise ``` ###### Parameters | Parameter | Type | | --------- | ----------------------------------------------------------------------- | | `url` | `string` | | `config`? | [`ConnectionConfig`](/reference/javascript/websocket/#connectionconfig) | ###### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`default`](/reference/javascript/websocket/#default)> **Source**: ## Interfaces []() ### CloseFrame #### Properties | Property | Type | Defined in | | ------------ | -------- | ------------------------------------------------------------------------------------------------------------- | | []()`code` | `number` | **Source**: | | []()`reason` | `string` | **Source**: | *** []() ### ConnectionConfig #### Properties | Property | Type | Description | Defined in | | --------------------------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | | []()`acceptUnmaskedFrames?` | `boolean` | When set to true, the server will accept and handle unmasked frames from the client. According to the RFC 6455, the server must close the connection to the client in such cases, however it seems like there are some popular libraries that are sending unmasked frames, ignoring the RFC. By default this option is set to false, i.e. according to RFC 6455. | **Source**: | | []()`headers?` | `HeadersInit` | Additional connect request headers. | **Source**: | | []()`maxFrameSize?` | `number` \| `"none"` | The maximum size of a single incoming message frame. The string “none” means no size limit. The limit is for frame payload NOT including the frame header. The default value is 16 MiB which should be reasonably big for all normal use-cases but small enough to prevent memory eating by a malicious user. | **Source**: | | []()`maxMessageSize?` | `number` \| `"none"` | The maximum size of an incoming message. The string “none” means no size limit. The default value is 64 MiB which should be reasonably big for all normal use-cases but small enough to prevent memory eating by a malicious user. | **Source**: | | []()`maxWriteBufferSize?` | `number` | The max size of the write buffer in bytes. Setting this can provide backpressure in the case the write buffer is filling up due to write errors. The default value is unlimited. Note: The write buffer only builds up past write\_buffer\_size when writes to the underlying stream are failing. So the write buffer can not fill up if you are not observing write errors. Note: Should always be at least write\_buffer\_size + 1 message and probably a little more depending on error handling strategy. | **Source**: | | []()`readBufferSize?` | `number` | Read buffer capacity. The default value is 128 KiB. | **Source**: | | []()`writeBufferSize?` | `number` | The target minimum size of the write buffer to reach before writing the data to the underlying stream. The default value is 128 KiB. If set to 0 each message will be eagerly written to the underlying stream. It is often more optimal to allow them to buffer a little, hence the default value. | **Source**: | *** []() ### MessageKind\ #### Type Parameters | Type Parameter | | -------------- | | `T` | | `D` | #### Properties | Property | Type | Defined in | | ---------- | ---- | ------------------------------------------------------------------------------------------------------------- | | []()`data` | `D` | **Source**: | | []()`type` | `T` | **Source**: | ## Type Aliases []() ### Message ```ts type Message: | MessageKind<"Text", string> | MessageKind<"Binary", number[]> | MessageKind<"Ping", number[]> | MessageKind<"Pong", number[]> | MessageKind<"Close", CloseFrame | null>; ``` **Source**: # @tauri-apps/plugin-window-state ## Enumerations []() ### StateFlags #### Enumeration Members []() ##### ALL ```ts ALL: 63; ``` **Source**: []() ##### DECORATIONS ```ts DECORATIONS: 16; ``` **Source**: []() ##### FULLSCREEN ```ts FULLSCREEN: 32; ``` **Source**: []() ##### MAXIMIZED ```ts MAXIMIZED: 4; ``` **Source**: []() ##### POSITION ```ts POSITION: 2; ``` **Source**: []() ##### SIZE ```ts SIZE: 1; ``` **Source**: []() ##### VISIBLE ```ts VISIBLE: 8; ``` **Source**: ## Functions []() ### filename() ```ts function filename(): Promise ``` Get the name of the file used to store window state. #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`> **Source**: *** []() ### restoreState() ```ts function restoreState(label, flags?): Promise ``` Restore the state for the specified window from disk. #### Parameters | Parameter | Type | | --------- | -------------------------------------------------------------- | | `label` | `string` | | `flags`? | [`StateFlags`](/reference/javascript/window-state/#stateflags) | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: *** []() ### restoreStateCurrent() ```ts function restoreStateCurrent(flags?): Promise ``` Restore the state for the current window from disk. #### Parameters | Parameter | Type | | --------- | -------------------------------------------------------------- | | `flags`? | [`StateFlags`](/reference/javascript/window-state/#stateflags) | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: *** []() ### saveWindowState() ```ts function saveWindowState(flags?): Promise ``` Save the state of all open windows to disk. #### Parameters | Parameter | Type | | --------- | -------------------------------------------------------------- | | `flags`? | [`StateFlags`](/reference/javascript/window-state/#stateflags) | #### Returns [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`> **Source**: # Webview Versions ## WebView2 (Windows) Tauri uses WebView2 which is based on Microsoft Edge and therefore Chromium. WebView2 can update itself, you are guaranteed a relatively recent chromium build on all Windows targets. WebView2 is supported on Windows 7 and newer and comes preinstalled on Windows 11. On versions older than Windows 11 the installer generated by Tauri takes care of ensuring WebView2 is installed on the system. ## Android WebView (Android) Tauri uses the system [Android WebView](https://developer.chrome.com/docs/webview), which is based on Chromium. Tauri does not bundle a WebView with your app, so the runtime version depends on the device’s currently selected WebView provider. On most production Android devices, WebView is an updatable system component. Some Android images can use a different preinstalled provider or allow switching providers in developer settings, so web platform support is tied to that provider’s Chromium/WebView version. To check the version used by a development build, open the [Android Web Inspector](/develop/#opening-the-web-inspector) and inspect the running WebView with Chrome DevTools. You can also check the selected WebView provider and app version in Android’s developer settings. ## WebKit (macOS, iOS, & Linux) Tauri uses WebKit on macOS (through [WKWebView](https://developer.apple.com/documentation/webkit/wkwebview?language=objc)) and Linux (through `webkit2gtk`). ### Interpreting WebKit Version Numbers Webkit version numbers are quite complicated, so below is some helpful information to understand them. WebKit version numbers are made up of 5 segments and a numeric prefix indicating which OS WebKit is built for: > `$(SYSTEM_VERSION_PREFIX)$(MAJOR_VERSION).$(MINOR_VERSION).$(TINY_VERSION).$(MICRO_VERSION).$(NANO_VERSION)` The numeric prefix is called the `SYSTEM_VERSION_PREFIX` and seems to be only present for macOS and iOS builds (not for Linux). Furthermore, if the last two segments are both `0` they can be omitted (so a version like `613.2.7.0.0` would be referred to as `613.2.7`). As an example, the WebKit version shipped with Safari 15.5 on macOS Monterey (12.x) has the version number `17613.2.7.1.8`. You can interpret it like this: * `SYSTEM_VERSION_PREFIX`: 17 * `MAJOR_VERSION`: 613 * `MINOR_VERSION`: 2 * `TINY_VERSION`: 7 * `MICRO_VERSION`: 1 * `NANO_VERSION`: 8 Here is what the `SYSTEM_VERSION_PREFIX` values map to: | macOS version | `SYSTEM_VERSION_PREFIX` | | ------------- | ----------------------- | | sdk=iphone\* | 8 | | 14.0 | 19 | | 13.0 | 18 | | 12.0 | 17 | | 11.0 | 16 | | 10.15 | 15 | | 10.14 | 14 | | 10.13 | 13 | | 10.12 | 12 | | 10.11 | 11 | ### macOS & iOS On macOS, Tauri uses the webview that comes preinstalled with macOS since version 10.10 (Yosemite). It is considered a core component and is therefore updated with the regular OS updates. This means unsupported macOS versions **do not** receive WebKit updates. To find the WebKit version used by `WKWebView` on your version of macOS you can use this command in the terminal: ```shell awk '/CFBundleVersion/{getline;gsub(/<[^>]*>/,"");print}' /System/Library/Frameworks/WebKit.framework/Resources/Info.plist ``` #### WebKit Versions in Safari The table below maps an OS version to the corresponding WebKit Safari versions so that you can use sites like [caniuse](https://caniuse.com) to figure out if a specific web platform feature is supported. | OS Name | OS Version | WebKit Version | Safari Version | Notes | | ----------- | -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Sonoma | 14.0 (Beta) | 616.1.14.11.11 | 17.0 | Verified on a 2023 M2 14“ MacBook Pro | | Ventura | 13.4.1 | 615.2.9.11.7 | 16.5.1 | Verified on a 2023 M2 14“ MacBook Pro | | | 13.3.1 | 615.1.26.11.23 | | Verified on a 2023 M2 14“ MacBook Pro | | | 13.3 | 615.1.26.11.22 | 16.4 | Verified on a 2023 M2 14“ MacBook Pro | | | 13.2.1 | 614.4.6.1.6 | | | | | 13.2 | ? | 16.3 | | | | 13.1 | 614.3.7.1.5 | 16.2 | Verified on a 2020 M1 13“ MacBook Pro | | | 13.0.1 | | | Verified on a 2020 M1 13“ MacBook Pro | | | 13.0 | 614.2.9.1.12 | 16.1 | Verified on a 2020 M1 13“ MacBook Pro | | Monterey | 12.6 | | | Verified on a 2020 M1 13“ MacBook Pro | | | 12.5.1 | 613.3.9.1.16 | 15.6.1 | Verified on a 2020 M1 13“ MacBook Pro | | | 12.5 | [613.3.9.1.5](https://github.com/WebKit/WebKit/blob/7f88b99524540e94abcdef4d45c1c0324d63fb56/Source/WebKit/Configurations/Version.xcconfig) | 15.6 | Verified on a 2020 M1 13“ MacBook Pro | | | 12.4 | [613.2.7.1.8](https://github.com/WebKit/WebKit/blob/b85867ab0dadcd371dd9859feff9033885748d47/Source/WebKit/Configurations/Version.xcconfig) | 15.5 | Verified on a 2020 M1 13“ MacBook Pro | | | 12.3.1 | [613.1.17.1.13](https://github.com/WebKit/WebKit/blob/8b92a7625ab76aed000ee5a3a1f6b68b20404449/Source/WebKit/Configurations/Version.xcconfig) | | | | | 12.3 | [613.1.17.1.6](https://github.com/WebKit/WebKit/blob/151e184ecb1d669996ac6139f28640b1c71184e1/Source/WebKit/Configurations/Version.xcconfig) | 15.4 | | | | 12.2.1 | [612.4.9.1.8](https://github.com/WebKit/WebKit/blob/cf0263b49d5753432d651e14537ed44e6185dc16/Source/WebKit/Configurations/Version.xcconfig) | | | | | 12.2 | [612.4.9.1.5](https://github.com/WebKit/WebKit/blob/c4c7b01e26d3142b0e0d456381c6d313399c3269/Source/WebKit/Configurations/Version.xcconfig) | 15.3 | | | | 12.1.1 | | | | | | 12.1 | [612.3.6.1.6](https://github.com/WebKit/WebKit/blob/2d561c2c5b8c1d12d85a6e52fe7e7e83ff179a15/Source/WebKit/Configurations/Version.xcconfig) | 15.2 | | | | 12.0.1 | [612.2.9.1.20](https://github.com/WebKit/WebKit/blob/0c76deb88d1c3b290ea6f8edf469929d08afe53c/Source/WebKit/Configurations/Version.xcconfig) | 15.1 | | | | 12.0 | [612.1.29.41.4](https://github.com/WebKit/WebKit/blob/983520ffb8f364ee765d081e0f51b6b66da3945b/Source/WebKit/Configurations/Version.xcconfig) | 15.0 | | | Big Sur | 11.6.7 | | | | | | 11.6.6 | | | | | | 11.6.5 | | | | | | 11.6.2 | | | | | | 11.6.1 | | | | | | 11.6 | | | | | | 11.5.2 | [611.3.10.1.6](https://github.com/WebKit/WebKit/blob/54099b931b220cf75dea154bb2e84a6a0582e87c/Source/WebKit/Configurations/Version.xcconfig) | | | | | 11.5.1 | | | | | | 11.5 | [611.3.10.1.3](https://github.com/WebKit/WebKit/blob/7253374f3302a64a15482d5303925d0cfa5eb610/Source/WebKit/Configurations/Version.xcconfig) | 14.1.2 | | | | 11.4 | [611.2.7.1.4](https://github.com/WebKit/WebKit/blob/200180885a516f378d0253ffc7b950f98b3f9810/Source/WebKit/Configurations/Version.xcconfig) | 14.1.1 | | | | 11.3.1 | | | | | | 11.3 | [611.1.21.161.3](https://github.com/WebKit/WebKit/blob/7aaa117b91a6822c40761d6f4da2e3d27627602f/Source/WebKit/Configurations/Version.xcconfig) | 14.1 | 24“ M1 iMac received a special WebKit version [611.1.21.1.12](https://github.com/WebKit/WebKit/blob/5aebddad42f6572ffb20d1cd1be8d22be9cf0101/Source/WebKit/Configurations/Version.xcconfig) | | | 11.2.3 | [610.4.3.1.7](https://github.com/WebKit/WebKit/blob/248c3283ebdec8bd8ae05d4d1d56390b0da28f27/Sour.3ce/WebKit/Configurations/Version.xcconfig) | | | | | 11.2.2 | | | | | | 11.2.1 | | | | | | 11.2 | [610.4.3.1.4](https://github.com/WebKit/WebKit/blob/b152d7889c786689406f203cc4eefea509a90302/Source/WebKit/Configurations/Version.xcconfig) | 14.0.3 | | | | 11.1 | [610.3.7.1.9](https://github.com/WebKit/WebKit/blob/62e4387a5eab36ed075961d9ee9971f8c01a55bd/Source/WebKit/Configurations/Version.xcconfig) | 14.0.2 | | | | 11.0.1 | [610.2.11.51.8](https://github.com/WebKit/WebKit/blob/388eae2d649eaecadaa11e1edc4248e54db583f7/Source/WebKit/Configurations/Version.xcconfig) | | | | | 11.0 | [610.2.11.1.3](https://github.com/WebKit/WebKit/blob/f11e10bcbb474d8c65a870cc680b0964d6529748/Source/WebKit/Configurations/Version.xcconfig) | 14.0.1 | Safari 14.0 was only ever available on iPhones | | Catalina | 10.15.7 Security Update 2022-004 | [609.4.1.1.1](https://github.com/WebKit/WebKit/blob/8df64286794c38efa4697b7c24658cb85204a070/Source/WebKit/Configurations/Version.xcconfig) | | | | | 10.15.7 | [609.4.1](https://github.com/WebKit/WebKit/blob/cb927e6151b5ef49c9ccfb13018f51471f8f1035/Source/WebKit/Configurations/Version.xcconfig) | 13.1.3 | | | | 10.15.6 | [609.3.5.1.3](https://github.com/WebKit/WebKit/blob/30fc8a44f087596c60e98adb434c0b98eccb61bb/Source/WebKit/Configurations/Version.xcconfig) | 13.1.2 | | | | 10.15.5 | [609.2.9.1.2](https://github.com/WebKit/WebKit/blob/ca54d252f3416c3ec64f80a084cb5c4ff7ba24f1/Source/WebKit/Configurations/Version.xcconfig) | 13.1.1 | | | | 10.15.4 | [609.1.20.111.8](https://github.com/WebKit/WebKit/blob/5c90480a38a86464b6b421c2fd28c744b43a4faa/Source/WebKit/Configurations/Version.xcconfig) | 13.1 | | | | 10.15.3 | [608.5.11](https://github.com/WebKit/WebKit/blob/e0e5c8297429016745b55545b1454f02e40d83e1/Source/WebKit/Configurations/Version.xcconfig) | 13.0.5 | | | | 10.15.2 | [608.4.9.1.3](https://github.com/WebKit/WebKit/blob/37f92d461f8ff74ea5cbe8f0baac0b8c8f1f6e19/Source/WebKit/Configurations/Version.xcconfig) | 13.0.4 | | | | 10.15.1 | [608.3.10.1.4](https://github.com/WebKit/WebKit/blob/ba26f5d986fca25516e6e72bc35c89905b1ed39a/Source/WebKit/Configurations/Version.xcconfig) | 13.0.3 | Verified on a 2014 15“ MacBook Pro | | | 10.15 | [608.2.30.1.1](https://github.com/WebKit/WebKit/blob/7b6a3e211037e2580cec885316f027a4b5b11b2d/Source/WebKit/Configurations/Version.xcconfig) | 13.0.2 | | | Mojave | 10.14.6 | [608.1.49](https://trac.webkit.org/browser/webkit/releases/Apple/Safari%2013.0/WebKit/Configurations/Version.xcconfig) | 13.0 | | | | 10.14.4 | [607.1.40.1.5](https://trac.webkit.org/browser/webkit/releases/Apple/Safari%2012.1/WebKit/Configurations/Version.xcconfig) | 12.1 | | | | 10.14.3 | [606.4.5](https://github.com/WebKit/WebKit/blob/a833f886f9bd68c279322104c27498245d5b8dfb/Source/WebKit/Configurations/Version.xcconfig) | 12.0.3 | | | | 10.14.2 | [606.3.4](https://github.com/WebKit/WebKit/blob/676f488e26ea1f872a9b69756c17d417b5317f52/Source/WebKit/Configurations/Version.xcconfig) | 12.0.2 | | | | 10.14.1 | [606.2.104.1.1](https://github.com/WebKit/WebKit/blob/244ed4eb99ff394551c3d38fec58c1848b0ecdc3/Source/WebKit/Configurations/Version.xcconfig) | 12.0.1 | | | | 10.14 | [606.2.11](https://trac.webkit.org/browser/webkit/releases/Apple/Safari%2012.0/WebKit/Configurations/Version.xcconfig) | 12.0 | | | High Sierra | 10.13.6 | [605.3.8](https://github.com/WebKit/WebKit/blob/266f0468e067e0c2c0e1209313a34bdf5926aa38/Source/WebKit/Configurations/Version.xcconfig) | 11.1.2 | | | | 10.13.5 | [605.2.8](https://github.com/WebKit/WebKit/blob/66a695280db148a4f8306c95c62e891b34ff3f86/Source/WebKit/Configurations/Version.xcconfig) | 11.1.1 | | | | 10.13.4 Security Update 2018-001 | [605.1.33.1.4](https://github.com/WebKit/WebKit/blob/69c0509d70d600dedaf55f448db8d887908b218c/Source/WebKit/Configurations/Version.xcconfig) | 11.1 | | | | 10.13.4 | [605.1.33.1.2](https://github.com/WebKit/WebKit/blob/25c0a6e3ca8e4a2dd41d4dcf52d70f27a912fef4/Source/WebKit/Configurations/Version.xcconfig) | 11.1 | | | | 10.13.3 | [604.5.6](https://github.com/WebKit/WebKit/blob/3f76b1214e0deb75a2f813be9bd96b56d9da84df/Source/WebKit/Configurations/Version.xcconfig) | 11.0.3 | | | | 10.13.2 Supplemental Update | [604.4.7.1.6](https://github.com/WebKit/WebKit/blob/68ee2c6176b6d03fbee855cd727c9cf9b09314b1/Source/WebKit/Configurations/Version.xcconfig) | 11.0.2 | 27“ iMac Pro received a special WebKit version [604.4.7.10.6](https://github.com/WebKit/WebKit/blob/00051d7d17eb097dd60908d93a94a072080dec08/Source/WebKit/Configurations/Version.xcconfig) | | | 10.13.2 | [604.4.7.1.3](https://github.com/WebKit/WebKit/blob/abe6ee6ad0f8fe44bd9ba476c818e4905c921ad3/Source/WebKit/Configurations/Version.xcconfig) | 11.0.2 | 27“ iMac Pro received a special WebKit version [604.4.7.10.4](https://github.com/WebKit/WebKit/blob/1122bda2378b8a88d24b01a585f17e4286f14752/Source/WebKit/Configurations/Version.xcconfig) | | | 10.13.1 | [604.3.5](https://trac.webkit.org/browser/webkit/releases/Apple/Safari%2011.0.1/WebKit/Configurations/Version.xcconfig) | 11.0.1 | | | | 10.13 | [604.1.38.1.6](https://github.com/WebKit/WebKit/blob/62f5206fadd2fd99c6e3060df4f57a7b7ddbbd1e/Source/WebKit/Configurations/Version.xcconfig) | 11.0 | | ### Linux The diverse nature of the Linux ecosystem means it is very hard to compile accurate information about WebKitGTK on the various distros. The table below is a very incomplete list of the most commonly used distributions and their WebKit versions. You should always check your distro’s repositories for up-to-date information. | Distro | `webkitgtk` Version | WebKit Version | Safari Equivalent | | ----------------------------------------------------------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------ | ----------------- | | Debian 11 (with update), Ubuntu 20.04 (with update), Ubuntu 22.04 | 2.36 | [614.1.6](https://trac.webkit.org/browser/webkit/releases/WebKitGTK/webkit-2.36/Source/WebKit/Configurations/Version.xcconfig) | TP 140 (16.0) | | Debian 10 (with update) | 2.34 | [613.1.1](https://trac.webkit.org/browser/webkit/releases/WebKitGTK/webkit-2.34/Source/WebKit/Configurations/Version.xcconfig) | 15.4 | | Debian 11, Ubuntu 18.04 (with update), centos 8 (non-stream) | 2.32 | [612.1.6](https://trac.webkit.org/browser/webkit/releases/WebKitGTK/webkit-2.32/Source/WebKit/Configurations/Version.xcconfig) | 15.0 | | Ubuntu 20.04 | 2.28 | [610.1.1](https://trac.webkit.org/browser/webkit/releases/WebKitGTK/webkit-2.28/Source/WebKit/Configurations/Version.xcconfig) | 14.0 | | Debian 9 (with backport), Debian 10 | 2.24 | [608.1.6](https://trac.webkit.org/browser/webkit/releases/WebKitGTK/webkit-2.24/Source/WebKit/Configurations/Version.xcconfig) | 13.0 | | Ubuntu 18.04 | 2.20 | [606.1.4](https://trac.webkit.org/browser/webkit/releases/WebKitGTK/webkit-2.20/Source/WebKit/Configurations/Version.xcconfig) | 12.0 |