diff --git a/src/content/docs/features/autostart.mdx b/src/content/docs/features/autostart.mdx index 49448928ac..852dd27a78 100644 --- a/src/content/docs/features/autostart.mdx +++ b/src/content/docs/features/autostart.mdx @@ -4,7 +4,7 @@ description: Automatically launch your app at system startup. --- import PluginLinks from '@components/PluginLinks.astro'; -import { Tabs, TabItem } from '@astrojs/starlight/components'; +import { Tabs, TabItem, Steps } from '@astrojs/starlight/components'; import CommandTabs from '@components/CommandTabs.astro'; @@ -24,44 +24,47 @@ Install the autostart plugin to get started. -Use your project's package manager to add the dependency: + Use your project's package manager to add the dependency: -{' '} + {' '} - + - + + -1. Run `cargo add tauri-plugin-autostart` to add the plugin to the project's dependencies in `Cargo.toml`. + 1. Run `cargo add tauri-plugin-autostart` to add the plugin to the project's dependencies in `Cargo.toml`. -2. Modify `lib.rs` to initialize the plugin: + 2. Modify `lib.rs` to initialize the plugin: -```rust title="lib.rs" ins={1, 6} -use tauri_plugin_autostart::MacosLauncher; + ```rust title="lib.rs" ins={1, 6} + use tauri_plugin_autostart::MacosLauncher; -#[cfg_attr(mobile, tauri::mobile_entry_point)] -fn run() { - tauri::Builder::default() - .plugin(tauri_plugin_autostart::init(MacosLauncher::LaunchAgent, Some(vec!["--flag1", "--flag2"]) /* arbitrary number of args to pass to your app */)) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); -} -``` + #[cfg_attr(mobile, tauri::mobile_entry_point)] + fn run() { + tauri::Builder::default() + .plugin(tauri_plugin_autostart::init(MacosLauncher::LaunchAgent, Some(vec!["--flag1", "--flag2"]) /* arbitrary number of args to pass to your app */)) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); + } + ``` -3. You can install the JavaScript Guest bindings using your preferred JavaScript package manager: + 3. You can install the JavaScript Guest bindings using your preferred JavaScript package manager: - - + + + + ## Usage diff --git a/src/content/docs/features/barcode-scanner.mdx b/src/content/docs/features/barcode-scanner.mdx index 425c77f640..978238e1e6 100644 --- a/src/content/docs/features/barcode-scanner.mdx +++ b/src/content/docs/features/barcode-scanner.mdx @@ -8,7 +8,7 @@ sidebar: --- import PluginLinks from '@components/PluginLinks.astro'; -import { Tabs, TabItem } from '@astrojs/starlight/components'; +import { Tabs, TabItem, Steps } from '@astrojs/starlight/components'; import CommandTabs from '@components/CommandTabs.astro'; @@ -29,41 +29,44 @@ Install the barcode-scanner plugin to get started. -Use your project's package manager to add the dependency: + Use your project's package manager to add the dependency: -{' '} - - + {' '} + + + -1. Run `cargo add tauri-plugin-barcode-scanner` to add the plugin to the project's dependencies in `Cargo.toml`. + 1. Run `cargo add tauri-plugin-barcode-scanner` to add the plugin to the project's dependencies in `Cargo.toml`. -2. Modify `lib.rs` to initialize the plugin: + 2. Modify `lib.rs` to initialize the plugin: -```rust title="lib.rs" ins={4} -#[cfg_attr(mobile, tauri::mobile_entry_point)] -fn run() { - tauri::Builder::default() - .plugin(tauri_plugin_barcode_scanner::init()) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); -} -``` + ```rust title="lib.rs" ins={4} + #[cfg_attr(mobile, tauri::mobile_entry_point)] + fn run() { + tauri::Builder::default() + .plugin(tauri_plugin_barcode_scanner::init()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); + } + ``` + + 3. Install the JavaScript Guest bindings using your preferred JavaScript package manager: -3. Install the JavaScript Guest bindings using your preferred JavaScript package manager: + - + diff --git a/src/content/docs/features/cli.mdx b/src/content/docs/features/cli.mdx index 1a4fa409c5..daa1c348cf 100644 --- a/src/content/docs/features/cli.mdx +++ b/src/content/docs/features/cli.mdx @@ -4,7 +4,7 @@ description: Parse arguments from the command line interface. --- import PluginLinks from '@components/PluginLinks.astro'; -import { Tabs, TabItem } from '@astrojs/starlight/components'; +import { Tabs, TabItem, Steps } from '@astrojs/starlight/components'; import CommandTabs from '@components/CommandTabs.astro'; @@ -24,52 +24,55 @@ _This plugin requires a Rust version of at least **1.75**_ Install the CLI plugin to get started. - - -Use your project's package manager to add the dependency: - -{' '} - - - - - - -1. Install the Core plugin by adding the following to your `Cargo.toml` file: - -```toml title="src-tauri/Cargo.toml" -# you can add the dependencies on the `[dependencies]` section if you do not target mobile -[target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies] -tauri-plugin-cli = "2.0.0-beta" -# alternatively with Git: -tauri-plugin-cli = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } -``` - -2. Modify `lib.rs` to initialize the plugin: - -```rust title="src-tauri/src/lib.rs" ins={4} -#[cfg_attr(mobile, tauri::mobile_entry_point)] -fn run() { - tauri::Builder::default() - .plugin(tauri_plugin_cli::init()) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); -} -``` - -3. Install the JavaScript Guest bindings using your preferred JavaScript package manager: - - - + + + Use your project's package manager to add the dependency: + + {' '} + + + + + + + + 1. Install the Core plugin by adding the following to your `Cargo.toml` file: + + ```toml title="src-tauri/Cargo.toml" + # you can add the dependencies on the `[dependencies]` section if you do not target mobile + [target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies] + tauri-plugin-cli = "2.0.0-beta" + # alternatively with Git: + tauri-plugin-cli = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } + ``` + + 2. Modify `lib.rs` to initialize the plugin: + + ```rust title="src-tauri/src/lib.rs" ins={4} + #[cfg_attr(mobile, tauri::mobile_entry_point)] + fn run() { + tauri::Builder::default() + .plugin(tauri_plugin_cli::init()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); + } + ``` + + 3. Install the JavaScript Guest bindings using your preferred JavaScript package manager: + + + + + ## Base Configuration diff --git a/src/content/docs/features/clipboard.mdx b/src/content/docs/features/clipboard.mdx index 3ddcdd0199..ce5d205d9f 100644 --- a/src/content/docs/features/clipboard.mdx +++ b/src/content/docs/features/clipboard.mdx @@ -5,7 +5,7 @@ description: Read and write to the system clipboard. import Stub from '@components/Stub.astro'; import PluginLinks from '@components/PluginLinks.astro'; -import { Tabs, TabItem } from '@astrojs/starlight/components'; +import { Tabs, TabItem, Steps } from '@astrojs/starlight/components'; import CommandTabs from '@components/CommandTabs.astro'; @@ -28,33 +28,34 @@ Install the clipboard plugin to get started. + - 1. Run `cargo add tauri-plugin-clipboard-manager` to add the plugin to the project's dependencies in `Cargo.toml`. + 1. Run `cargo add tauri-plugin-clipboard-manager` to add the plugin to the project's dependencies in `Cargo.toml`. - 2. Modify `lib.rs` to initialize the plugin: + 2. Modify `lib.rs` to initialize the plugin: - ```rust - // lib.rs - #[cfg_attr(mobile, tauri::mobile_entry_point)] - pub fn run() { - tauri::Builder::default() - // Initialize the plugin - .plugin(tauri_plugin_clipboard_manager::init()) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); - } - ``` + ```rust + // lib.rs + #[cfg_attr(mobile, tauri::mobile_entry_point)] + pub fn run() { + tauri::Builder::default() + // Initialize the plugin + .plugin(tauri_plugin_clipboard_manager::init()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); + } + ``` - 3. If you'd like to manage the clipboard in JavaScript then install the npm package as well: + 3. If you'd like to manage the clipboard in JavaScript then install the npm package as well: - + + - ## Usage diff --git a/src/content/docs/features/deep-linking.mdx b/src/content/docs/features/deep-linking.mdx index a4b79cacc8..060c239b9b 100644 --- a/src/content/docs/features/deep-linking.mdx +++ b/src/content/docs/features/deep-linking.mdx @@ -8,7 +8,7 @@ sidebar: --- import PluginLinks from '@components/PluginLinks.astro'; -import { Tabs, TabItem } from '@astrojs/starlight/components'; +import { Tabs, TabItem, Steps } from '@astrojs/starlight/components'; import CommandTabs from '@components/CommandTabs.astro'; @@ -29,41 +29,44 @@ Install the deep-link plugin to get started. -Use your project's package manager to add the dependency: + Use your project's package manager to add the dependency: -{' '} + {' '} - + - -1. Run `cargo add tauri-plugin-deep-link` to add the plugin to the project's dependencies in `Cargo.toml`. - -2. Modify `lib.rs` to initialize the plugin: - -```rust title="lib.rs" ins={4} -#[cfg_attr(mobile, tauri::mobile_entry_point)] -fn run() { - tauri::Builder::default() - .plugin(tauri_plugin_deep_link::init()) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); -} -``` - -3. Install the JavaScript Guest bindings using your preferred JavaScript package manager: - - + + + 1. Run `cargo add tauri-plugin-deep-link` to add the plugin to the project's dependencies in `Cargo.toml`. + + 2. Modify `lib.rs` to initialize the plugin: + + ```rust title="lib.rs" ins={4} + #[cfg_attr(mobile, tauri::mobile_entry_point)] + fn run() { + tauri::Builder::default() + .plugin(tauri_plugin_deep_link::init()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); + } + ``` + + 3. Install the JavaScript Guest bindings using your preferred JavaScript package manager: + + + + diff --git a/src/content/docs/features/dialog.mdx b/src/content/docs/features/dialog.mdx index 6277d92204..c8754acf38 100644 --- a/src/content/docs/features/dialog.mdx +++ b/src/content/docs/features/dialog.mdx @@ -7,7 +7,7 @@ tableOfContents: --- import PluginLinks from '@components/PluginLinks.astro'; -import { Tabs, TabItem } from '@astrojs/starlight/components'; +import { Tabs, TabItem, Steps } from '@astrojs/starlight/components'; import CommandTabs from '@components/CommandTabs.astro'; @@ -21,41 +21,43 @@ Install the dialog plugin to get started. - Use your project's package manager to add the dependency: + Use your project's package manager to add the dependency: - + - - - 1. Run `cargo add tauri-plugin-dialog` to add the plugin to the project's dependencies in `Cargo.toml`. - - 2. Modify `lib.rs` to initialize the plugin: - - ```rust - // lib.rs - #[cfg_attr(mobile, tauri::mobile_entry_point)] - pub fn run() { - tauri::Builder::default() - // Initialize the plugin - .plugin(tauri_plugin_dialog::init()) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); - } - ``` - - 3. If you'd like create dialogs in JavaScript, install the npm package as well: - - - - + + + + 1. Run `cargo add tauri-plugin-dialog` to add the plugin to the project's dependencies in `Cargo.toml`. + + 2. Modify `lib.rs` to initialize the plugin: + + ```rust + // lib.rs + #[cfg_attr(mobile, tauri::mobile_entry_point)] + pub fn run() { + tauri::Builder::default() + // Initialize the plugin + .plugin(tauri_plugin_dialog::init()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); + } + ``` + + 3. If you'd like create dialogs in JavaScript, install the npm package as well: + + + + + ## Usage diff --git a/src/content/docs/features/file-system.mdx b/src/content/docs/features/file-system.mdx index 4ffca78e84..268c209e8c 100644 --- a/src/content/docs/features/file-system.mdx +++ b/src/content/docs/features/file-system.mdx @@ -4,7 +4,7 @@ description: Access the file system. --- import PluginLinks from '@components/PluginLinks.astro'; -import { Tabs, TabItem } from '@astrojs/starlight/components'; +import { Tabs, TabItem, Steps } from '@astrojs/starlight/components'; import CommandTabs from '@components/CommandTabs.astro'; @@ -24,51 +24,54 @@ _This plugin requires a Rust version of at least **1.75**_ Install the fs plugin to get started. - - -Use your project's package manager to add the dependency: - -{ ' ' } - - - - - - -1. Install the fs plugin by adding the following to your `Cargo.toml` file: - -```toml title="src-tauri/Cargo.toml" -[dependencies] -tauri-plugin-fs = "2.0.0-beta" -# alternatively with Git: -tauri-plugin-fs = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } -``` - -2. Modify `lib.rs` to initialize the plugin: - -```rust title="src-tauri/src/lib.rs" ins={4} -#[cfg_attr(mobile, tauri::mobile_entry_point)] -fn run() { - tauri::Builder::default() - .plugin(tauri_plugin_fs::init()) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); -} -``` - -3. Install the JavaScript Guest bindings using your preferred JavaScript package manager: - - - + + + Use your project's package manager to add the dependency: + + { ' ' } + + + + + + + + 1. Install the fs plugin by adding the following to your `Cargo.toml` file: + + ```toml title="src-tauri/Cargo.toml" + [dependencies] + tauri-plugin-fs = "2.0.0-beta" + # alternatively with Git: + tauri-plugin-fs = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } + ``` + + 2. Modify `lib.rs` to initialize the plugin: + + ```rust title="src-tauri/src/lib.rs" ins={4} + #[cfg_attr(mobile, tauri::mobile_entry_point)] + fn run() { + tauri::Builder::default() + .plugin(tauri_plugin_fs::init()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); + } + ``` + + 3. Install the JavaScript Guest bindings using your preferred JavaScript package manager: + + + + + ## Usage diff --git a/src/content/docs/features/global-shortcut.mdx b/src/content/docs/features/global-shortcut.mdx index 4e4b14ab46..24673cf74c 100644 --- a/src/content/docs/features/global-shortcut.mdx +++ b/src/content/docs/features/global-shortcut.mdx @@ -4,7 +4,7 @@ description: Register global shortcuts. --- import PluginLinks from '@components/PluginLinks.astro'; -import { Tabs, TabItem } from '@astrojs/starlight/components'; +import { Tabs, TabItem, Steps } from '@astrojs/starlight/components'; import CommandTabs from '@components/CommandTabs.astro'; @@ -26,48 +26,51 @@ Install the global-shortcut plugin to get started. -Use your project's package manager to add the dependency: + Use your project's package manager to add the dependency: -{ ' ' } + { ' ' } - + - -1. Install the global-shortcut plugin by adding the following to your `Cargo.toml` file: - -```toml title="src-tauri/Cargo.toml" -# you can add the dependencies on the `[dependencies]` section if you do not target mobile -[target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies] -tauri-plugin-global-shortcut = "2.0.0-beta" -# alternatively with Git: -tauri-plugin-global-shortcut = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } -``` - -2. Modify `lib.rs` to initialize the plugin: - -```rust title="src-tauri/src/lib.rs" ins={3} -fn run() { - tauri::Builder::default() - .plugin(tauri_plugin_global_shortcut::Builder::new().build()) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); -} -``` - -3. Install the JavaScript Guest bindings using your preferred JavaScript package manager: - - + + + 1. Install the global-shortcut plugin by adding the following to your `Cargo.toml` file: + + ```toml title="src-tauri/Cargo.toml" + # you can add the dependencies on the `[dependencies]` section if you do not target mobile + [target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies] + tauri-plugin-global-shortcut = "2.0.0-beta" + # alternatively with Git: + tauri-plugin-global-shortcut = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } + ``` + + 2. Modify `lib.rs` to initialize the plugin: + + ```rust title="src-tauri/src/lib.rs" ins={3} + fn run() { + tauri::Builder::default() + .plugin(tauri_plugin_global_shortcut::Builder::new().build()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); + } + ``` + + 3. Install the JavaScript Guest bindings using your preferred JavaScript package manager: + + + + diff --git a/src/content/docs/features/http-client.mdx b/src/content/docs/features/http-client.mdx index 00c8f729f5..d9f2070fe5 100644 --- a/src/content/docs/features/http-client.mdx +++ b/src/content/docs/features/http-client.mdx @@ -4,7 +4,7 @@ description: Access the HTTP client written in Rust. --- import PluginLinks from '@components/PluginLinks.astro'; -import { Tabs, TabItem } from '@astrojs/starlight/components'; +import { Tabs, TabItem, Steps } from '@astrojs/starlight/components'; import CommandTabs from '@components/CommandTabs.astro'; @@ -18,42 +18,43 @@ Install the http plugin to get started. - Use your project's package manager to add the dependency: + Use your project's package manager to add the dependency: - + + - 1. Run `cargo add tauri-plugin-http` to add the plugin to the project's dependencies in `Cargo.toml`. + 1. Run `cargo add tauri-plugin-http` to add the plugin to the project's dependencies in `Cargo.toml`. - 2. Modify `lib.rs` to initialize the plugin: + 2. Modify `lib.rs` to initialize the plugin: - ```rust ins={6} - // lib.rs - #[cfg_attr(mobile, tauri::mobile_entry_point)] - pub fn run() { - tauri::Builder::default() - // Initialize the plugin - .plugin(tauri_plugin_http::init()) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); - } - ``` + ```rust ins={6} + // lib.rs + #[cfg_attr(mobile, tauri::mobile_entry_point)] + pub fn run() { + tauri::Builder::default() + // Initialize the plugin + .plugin(tauri_plugin_http::init()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); + } + ``` - 3. If you'd like to make http requests in JavaScript then install the npm package as well: + 3. If you'd like to make http requests in JavaScript then install the npm package as well: - + + - ## Usage @@ -62,37 +63,41 @@ The http plugin is available in both as an JavaScript API and in Rust as a [reqw ### JavaScript -1. To keep your app safe, configure allowed scope. Read more on [JavaScript API reference](/references/v2/js/http/#security). - -```json -//tauri.conf.json -{ - "plugins": { - "http": { - "scope": ["http://my.api.host/*"] - } - } -} -``` + -2. Send a request +1. To keep your app safe, configure allowed scope. Read more on [JavaScript API reference](/references/v2/js/http/#security). -```js -import { fetch } from '@tauri-apps/plugin-http'; + ```json + //tauri.conf.json + { + "plugins": { + "http": { + "scope": ["http://my.api.host/*"] + } + } + } + ``` -// Send a GET request -const response = await fetch('http://my.api.host/data.json', { - method: 'GET', -}); -console.log(response.status); // e.g. 200 -console.log(response.statusText); // e.g. "OK" -``` +2. Send a request + + ```js + import { fetch } from '@tauri-apps/plugin-http'; + + // Send a GET request + const response = await fetch('http://my.api.host/data.json', { + method: 'GET', + }); + console.log(response.status); // e.g. 200 + console.log(response.statusText); // e.g. "OK" + ``` + + :::note -:::note + The current `fetch` method is an API to Rust backend. It tries to be as close and compliant to the [`fetch` Web API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) as possible. -The current `fetch` method is an API to Rust backend. It tries to be as close and compliant to the [`fetch` Web API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) as possible. + ::: -::: + ### Rust diff --git a/src/content/docs/features/localhost.mdx b/src/content/docs/features/localhost.mdx index 364245b750..c916dd468c 100644 --- a/src/content/docs/features/localhost.mdx +++ b/src/content/docs/features/localhost.mdx @@ -4,7 +4,7 @@ description: Use a localhost server in production apps. --- import PluginLinks from '@components/PluginLinks.astro'; -import { Tabs, TabItem } from '@astrojs/starlight/components'; +import { Tabs, TabItem, Steps } from '@astrojs/starlight/components'; import CommandTabs from '@components/CommandTabs.astro'; @@ -24,26 +24,29 @@ This plugin brings considerable security risks and you should only use it if you ## Setup _This plugin requires a Rust version of at least **1.75**_ + -1. Install the localhost plugin by adding the following to your `Cargo.toml` file: +1. Install the localhost plugin by adding the following to your `Cargo.toml` file: -```toml title="src-tauri/Cargo.toml" -[dependencies] -tauri-plugin-localhost = "2.0.0-beta" -# alternatively with Git: -tauri-plugin-localhost = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } -``` + ```toml title="src-tauri/Cargo.toml" + [dependencies] + tauri-plugin-localhost = "2.0.0-beta" + # alternatively with Git: + tauri-plugin-localhost = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } + ``` -2. Modify `lib.rs` to initialize the plugin: +2. Modify `lib.rs` to initialize the plugin: -```rust title="src-tauri/src/lib.rs" ins={3} -fn run() { - tauri::Builder::default() - .plugin(tauri_plugin_localhost::Builder::new().build()) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); -} -``` + ```rust title="src-tauri/src/lib.rs" ins={3} + fn run() { + tauri::Builder::default() + .plugin(tauri_plugin_localhost::Builder::new().build()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); + } + ``` + + ## Usage diff --git a/src/content/docs/features/logging.mdx b/src/content/docs/features/logging.mdx index a675784422..fce29f0122 100644 --- a/src/content/docs/features/logging.mdx +++ b/src/content/docs/features/logging.mdx @@ -4,7 +4,7 @@ description: Configurable logging. --- import PluginLinks from '@components/PluginLinks.astro'; -import { Tabs, TabItem } from '@astrojs/starlight/components'; +import { Tabs, TabItem, Steps } from '@astrojs/starlight/components'; import CommandTabs from '@components/CommandTabs.astro'; @@ -27,90 +27,95 @@ Install the log plugin to get started. -Use your project's package manager to add the dependency: + Use your project's package manager to add the dependency: -{ ' ' } + { ' ' } - + - -1. Install the log plugin by adding the following to your `Cargo.toml` file: - -```toml title="src-tauri/Cargo.toml" -[dependencies] -tauri-plugin-log = "2.0.0-beta" -# alternatively with Git: -tauri-plugin-log = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } -``` - -2. Modify `lib.rs` to initialize the plugin: - -```rust title="src-tauri/src/lib.rs" ins={4} -#[cfg_attr(mobile, tauri::mobile_entry_point)] -fn run() { - tauri::Builder::default() - .plugin(tauri_plugin_log::Builder::new().build()) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); -} -``` - -3. Install the JavaScript Guest bindings using your preferred JavaScript package manager: - - + + + 1. Install the log plugin by adding the following to your `Cargo.toml` file: + + ```toml title="src-tauri/Cargo.toml" + [dependencies] + tauri-plugin-log = "2.0.0-beta" + # alternatively with Git: + tauri-plugin-log = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } + ``` + + 2. Modify `lib.rs` to initialize the plugin: + + ```rust title="src-tauri/src/lib.rs" ins={4} + #[cfg_attr(mobile, tauri::mobile_entry_point)] + fn run() { + tauri::Builder::default() + .plugin(tauri_plugin_log::Builder::new().build()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); + } + ``` + + 3. Install the JavaScript Guest bindings using your preferred JavaScript package manager: + + + + ## Usage -1. First, you need to register the plugin with Tauri. - -```rust title="src-tauri/src/lib.rs" {1} {6-14} -use tauri_plugin_log::{Target, TargetKind}; - -#[cfg_attr(mobile, tauri::mobile_entry_point)] -pub fn run() { - tauri::Builder::default() - .plugin( - tauri_plugin_log::Builder::new() - .targets([ - Target::new(TargetKind::Stdout), - Target::new(TargetKind::LogDir { file_name: None }), - Target::new(TargetKind::Webview), - ]) - .build(), - ) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); -} -``` + +1. First, you need to register the plugin with Tauri. + + ```rust title="src-tauri/src/lib.rs" {1} {6-14} + use tauri_plugin_log::{Target, TargetKind}; + + #[cfg_attr(mobile, tauri::mobile_entry_point)] + pub fn run() { + tauri::Builder::default() + .plugin( + tauri_plugin_log::Builder::new() + .targets([ + Target::new(TargetKind::Stdout), + Target::new(TargetKind::LogDir { file_name: None }), + Target::new(TargetKind::Webview), + ]) + .build(), + ) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); + } + ``` 2. Afterwards, all the plugin's APIs are available through the JavaScript guest bindings: -```js -import { trace, info, error, attachConsole } from '@tauri-apps/plugin-log'; + ```js + import { trace, info, error, attachConsole } from '@tauri-apps/plugin-log'; -// with TargetKind::Webview enabled, this function will print logs to the browser console -const detach = await attachConsole(); + // with TargetKind::Webview enabled, this function will print logs to the browser console + const detach = await attachConsole(); -trace('Trace'); -info('Info'); -error('Error'); + trace('Trace'); + info('Info'); + error('Error'); -// detach the browser console from the log stream -detach(); -``` + // detach the browser console from the log stream + detach(); + ``` + ## Permissions diff --git a/src/content/docs/features/notification.mdx b/src/content/docs/features/notification.mdx index 976e8b9606..ba0b5520a2 100644 --- a/src/content/docs/features/notification.mdx +++ b/src/content/docs/features/notification.mdx @@ -5,7 +5,7 @@ i18nReady: true --- import PluginLinks from '@components/PluginLinks.astro'; -import { Tabs, TabItem } from '@astrojs/starlight/components'; +import { Tabs, TabItem, Steps } from '@astrojs/starlight/components'; import CommandTabs from '@components/CommandTabs.astro'; import Stub from '@components/Stub.astro'; @@ -20,42 +20,43 @@ Install the notifications plugin to get started. - Use your project's package manager to add the dependency: + Use your project's package manager to add the dependency: - + + - 1. Run `cargo add tauri-plugin-notification` to add the plugin to the project's dependencies in `Cargo.toml`. + 1. Run `cargo add tauri-plugin-notification` to add the plugin to the project's dependencies in `Cargo.toml`. - 2. Modify `lib.rs` to initialize the plugin: + 2. Modify `lib.rs` to initialize the plugin: - ```rust - // lib.rs - #[cfg_attr(mobile, tauri::mobile_entry_point)] - pub fn run() { - tauri::Builder::default() - // Initialize the plugin - .plugin(tauri_plugin_notification::init()) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); - } - ``` + ```rust + // lib.rs + #[cfg_attr(mobile, tauri::mobile_entry_point)] + pub fn run() { + tauri::Builder::default() + // Initialize the plugin + .plugin(tauri_plugin_notification::init()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); + } + ``` - 3. If you'd like to use notifications in JavaScript then install the npm package as well: + 3. If you'd like to use notifications in JavaScript then install the npm package as well: - + + - ## Usage @@ -77,9 +78,13 @@ The notification plugin is available in both JavaScript and Rust. Follow these steps to send a notification: + 1. Check if permission is granted + 2. Request permission if not granted + 3. Send the notification + diff --git a/src/content/docs/features/os-info.mdx b/src/content/docs/features/os-info.mdx index d65d569443..2d5181e9b1 100644 --- a/src/content/docs/features/os-info.mdx +++ b/src/content/docs/features/os-info.mdx @@ -4,7 +4,7 @@ description: Read information about the operating system. --- import PluginLinks from '@components/PluginLinks.astro'; -import { Tabs, TabItem } from '@astrojs/starlight/components'; +import { Tabs, TabItem, Steps } from '@astrojs/starlight/components'; import CommandTabs from '@components/CommandTabs.astro'; @@ -16,7 +16,7 @@ Read information about the operating system using the OS Information plugin. Install the OS Information plugin to get started. - + Use your project's package manager to add the dependency: @@ -25,35 +25,36 @@ Install the OS Information plugin to get started. pnpm="pnpm tauri add os" cargo="cargo tauri add os" /> - - - - 1. Run `cargo add tauri-plugin-os` to add the plugin to the project's dependencies in `Cargo.toml`. - - 2. Modify `lib.rs` to initialize the plugin: - - ```rust - // lib.rs - #[cfg_attr(mobile, tauri::mobile_entry_point)] - pub fn run() { - tauri::Builder::default() - // Initialize the plugin - .plugin(tauri_plugin_os::init()) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); - } - ``` - - 3. If you'd like to use in JavaScript then install the npm package as well: - - - - - + + + + + 1. Run `cargo add tauri-plugin-os` to add the plugin to the project's dependencies in `Cargo.toml`. + + 2. Modify `lib.rs` to initialize the plugin: + + ```rust + // lib.rs + #[cfg_attr(mobile, tauri::mobile_entry_point)] + pub fn run() { + tauri::Builder::default() + // Initialize the plugin + .plugin(tauri_plugin_os::init()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); + } + ``` + + 3. If you'd like to use in JavaScript then install the npm package as well: + + + + + ## Usage diff --git a/src/content/docs/features/persisted-scope.mdx b/src/content/docs/features/persisted-scope.mdx index 86b8f36cc8..0a4ef3ed23 100644 --- a/src/content/docs/features/persisted-scope.mdx +++ b/src/content/docs/features/persisted-scope.mdx @@ -4,7 +4,7 @@ description: Persist runtime scope changes on the filesystem. --- import PluginLinks from '@components/PluginLinks.astro'; -import { Tabs, TabItem } from '@astrojs/starlight/components'; +import { Tabs, TabItem, Steps } from '@astrojs/starlight/components'; import CommandTabs from '@components/CommandTabs.astro'; @@ -27,26 +27,27 @@ Install the persisted-scope plugin to get started. Currently manual install is required for setting up persisted-scope plugin. ::: -1. Install the Core plugin by adding the following to your `Cargo.toml` file: - -```toml title="src-tauri/Cargo.toml" -[dependencies] -tauri-plugin-persisted-scope = "2.0.0-beta" -# alternatively with Git: -tauri-plugin-persisted-scope = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } -``` - -2. Modify `lib.rs` to initialize the plugin: - -```rust title="src-tauri/src/lib.rs" {3} -fn run() { - tauri::Builder::default() - .plugin(tauri_plugin_persisted_scope::init()) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); -} -``` - + +1. Install the Core plugin by adding the following to your `Cargo.toml` file: + + ```toml title="src-tauri/Cargo.toml" + [dependencies] + tauri-plugin-persisted-scope = "2.0.0-beta" + # alternatively with Git: + tauri-plugin-persisted-scope = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } + ``` + +2. Modify `lib.rs` to initialize the plugin: + + ```rust title="src-tauri/src/lib.rs" {3} + fn run() { + tauri::Builder::default() + .plugin(tauri_plugin_persisted_scope::init()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); + } + ``` + ## Usage After setup the plugin will automatically save and restore filesystem and asset scopes. diff --git a/src/content/docs/features/process.mdx b/src/content/docs/features/process.mdx index 4701ed8aca..a50b30c7aa 100644 --- a/src/content/docs/features/process.mdx +++ b/src/content/docs/features/process.mdx @@ -4,7 +4,7 @@ description: Access the current process. --- import PluginLinks from '@components/PluginLinks.astro'; -import { Tabs, TabItem } from '@astrojs/starlight/components'; +import { Tabs, TabItem, Steps } from '@astrojs/starlight/components'; import CommandTabs from '@components/CommandTabs.astro'; @@ -27,32 +27,34 @@ Install the plugin-process to get started. - - 1. Run `cargo add tauri-plugin-process` to add the plugin to the project's dependencies in `Cargo.toml`. - - 2. Modify `lib.rs` to initialize the plugin: - - ```rust ins={6} - // lib.rs - #[cfg_attr(mobile, tauri::mobile_entry_point)] - pub fn run() { - tauri::Builder::default() - // Initialize the plugin - .plugin(tauri_plugin_process::init()) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); - } - ``` - - 3. If you'd like to utilize the plugin in JavaScript then install the npm package as well: - - + + + 1. Run `cargo add tauri-plugin-process` to add the plugin to the project's dependencies in `Cargo.toml`. + + 2. Modify `lib.rs` to initialize the plugin: + + ```rust ins={6} + // lib.rs + #[cfg_attr(mobile, tauri::mobile_entry_point)] + pub fn run() { + tauri::Builder::default() + // Initialize the plugin + .plugin(tauri_plugin_process::init()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); + } + ``` + + 3. If you'd like to utilize the plugin in JavaScript then install the npm package as well: + + + + - ## Usage diff --git a/src/content/docs/features/single-instance.mdx b/src/content/docs/features/single-instance.mdx index 3100f77745..f3078898d0 100644 --- a/src/content/docs/features/single-instance.mdx +++ b/src/content/docs/features/single-instance.mdx @@ -71,10 +71,13 @@ The plugin is already installed and initialized, and it should be functioning co The plugin `init()` method takes a closure that is invoked when a new app instance was started, but closed by the plugin. The closure has three arguments: - + 1. **`app` :** The [AppHandle](https://docs.rs/tauri/latest/tauri/struct.AppHandle.html) of the application. + 2. **`args` :** The list of arguments, that was passed by the user to initiate this new instance. + 3. **`cwd` :** The Current Working Directory denotes the directory from which the new application instance was launched. + So, the closure should look like below diff --git a/src/content/docs/features/store.mdx b/src/content/docs/features/store.mdx index 5818361e8c..aaa1050682 100644 --- a/src/content/docs/features/store.mdx +++ b/src/content/docs/features/store.mdx @@ -4,7 +4,7 @@ description: Persistent key value storage. --- import PluginLinks from '@components/PluginLinks.astro'; -import { Tabs, TabItem } from '@astrojs/starlight/components'; +import { Tabs, TabItem, Steps } from '@astrojs/starlight/components'; import CommandTabs from '@components/CommandTabs.astro'; @@ -35,38 +35,37 @@ Install the store plugin to get started. - - 1. Install the store plugin by adding the following to your `Cargo.toml` file: - - ```toml title="src-tauri/Cargo.toml" - [dependencies] - tauri-plugin-store = "2.0.0-beta" - # alternatively with Git: - tauri-plugin-store = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } - ``` - - 2. Modify `lib.rs` to initialize the plugin: - - ```rust title="src-tauri/src/lib.rs" ins={4} - #[cfg_attr(mobile, tauri::mobile_entry_point)] - fn run() { - tauri::Builder::default() - .plugin(tauri_plugin_store::Builder::new().build()) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); - } - ``` - - 3. Install the JavaScript Guest bindings using your preferred JavaScript package manager: - - - + + 1. Install the store plugin by adding the following to your `Cargo.toml` file: + + ```toml title="src-tauri/Cargo.toml" + [dependencies] + tauri-plugin-store = "2.0.0-beta" + # alternatively with Git: + tauri-plugin-store = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } + ``` + + 2. Modify `lib.rs` to initialize the plugin: + + ```rust title="src-tauri/src/lib.rs" ins={4} + #[cfg_attr(mobile, tauri::mobile_entry_point)] + fn run() { + tauri::Builder::default() + .plugin(tauri_plugin_store::Builder::new().build()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); + } + ``` + + 3. Install the JavaScript Guest bindings using your preferred JavaScript package manager: + + + - ## Usage diff --git a/src/content/docs/features/window-state.mdx b/src/content/docs/features/window-state.mdx index 231d7ef30b..e4fc2ce804 100644 --- a/src/content/docs/features/window-state.mdx +++ b/src/content/docs/features/window-state.mdx @@ -4,7 +4,7 @@ description: Persist window sizes and positions. --- import PluginLinks from '@components/PluginLinks.astro'; -import { Tabs, TabItem } from '@astrojs/starlight/components'; +import { Tabs, TabItem, Steps } from '@astrojs/starlight/components'; import CommandTabs from '@components/CommandTabs.astro'; @@ -39,34 +39,37 @@ Use your project's package manager to add the dependency: + -1. Install the Core plugin by adding the following to your `Cargo.toml` file: + 1. Install the Core plugin by adding the following to your `Cargo.toml` file: -```toml title="src-tauri/Cargo.toml" -[dependencies] -tauri-plugin-window-state = "2.0.0-beta" -# alternatively with Git: -tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } -``` + ```toml title="src-tauri/Cargo.toml" + [dependencies] + tauri-plugin-window-state = "2.0.0-beta" + # alternatively with Git: + tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } + ``` -2. Modify `lib.rs` to initialize the plugin: + 2. Modify `lib.rs` to initialize the plugin: -```rust title="src-tauri/src/lib.rs" {3} -fn run() { - tauri::Builder::default() - .plugin(tauri_plugin_window_state::Builder::default().build()) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); -} -``` + ```rust title="src-tauri/src/lib.rs" {3} + fn run() { + tauri::Builder::default() + .plugin(tauri_plugin_window_state::Builder::default().build()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); + } + ``` + + 3. Install the JavaScript Guest bindings using your preferred JavaScript package manager: -3. Install the JavaScript Guest bindings using your preferred JavaScript package manager: + - +