HTTP Client
Make HTTP requests with the http plugin.
Supported Platforms
Section titled “Supported Platforms”This plugin requires a Rust version of at least 1.77.2
| Platform | Level | Notes |
|---|---|---|
| windows | ||
| linux | ||
| macos | ||
| android | ||
| ios |
Install the http plugin to get started.
Use your project’s package manager to add the dependency:
npm run tauri add httpyarn run tauri add httppnpm tauri add httpdeno task tauri add httpbun tauri add httpcargo tauri add httpRun the following command in the
src-taurifolder to add the plugin to the project’s dependencies inCargo.toml:cargo add tauri-plugin-http@2src-tauri/Cargo.toml tauri-plugin-opener = "2"serde = { version = "1", features = ["derive"] }serde_json = "1"tauri-plugin-http = "2"# Read the optimization guideline for more details: https://tauri.app/concept/size/#cargo-configurationModify
lib.rsto initialize the plugin. The example app keeps its builder chain in aconfigurefunction thatruncalls, so the plugin registers there. If yourrunholds the chain, add the same line there:src-tauri/src/lib.rs pub fn configure<R: tauri::Runtime>(builder: tauri::Builder<R>) -> tauri::Builder<R> {builder.plugin(tauri_plugin_opener::init()).plugin(tauri_plugin_http::init()).invoke_handler(tauri::generate_handler![greet])}If you’d like to make http requests in JavaScript then install the npm package as well:
npm install @tauri-apps/plugin-httpyarn add @tauri-apps/plugin-httppnpm add @tauri-apps/plugin-httpdeno add npm:@tauri-apps/plugin-httpbun add @tauri-apps/plugin-http
The HTTP plugin is available in both Rust as a reqwest re-export and JavaScript.
JavaScript
Section titled “JavaScript”Configure the allowed URLs. Until a permission grants the
fetchcommand, every request from the webview is denied by the ACL — and with the scope below, URLs outside the allow list (or matching a deny entry) stay rejected:src-tauri/capabilities/default.json "windows": ["main"],"permissions": ["core:default","opener:default""opener:default",{"identifier": "http:default","allow": [{"url": "https://*.tauri.app"}],"deny": [{"url": "https://private.tauri.app"}]}]}For more information, please see the documentation for Permissions Overview
Send a request. The
fetchmethod tries to be as close and compliant to thefetchWeb API as possible:src/main.ts import { invoke } from "@tauri-apps/api/core";import { fetch } from "@tauri-apps/plugin-http";let greetInputEl: HTMLInputElement | null;let greetMsgEl: HTMLElement | null;}}window.addEventListener("DOMContentLoaded", () => {window.addEventListener("DOMContentLoaded", async () => {greetInputEl = document.querySelector("#greet-input");greetMsgEl = document.querySelector("#greet-msg");document.querySelector("#greet-form")?.addEventListener("submit", (e) => {e.preventDefault();greet();});// Send a GET requestconst response = await fetch("https://test.tauri.app/data.json", {method: "GET",});console.log(response.status); // e.g. 200console.log(response.statusText); // e.g. "OK"});
In Rust you can utilize the reqwest crate re-exported by the plugin — for
example in a command that returns the HTTP status of a URL. For more details
refer to reqwest docs:
format!("Hello, {}! You've been greeted from Rust!", name)}
#[tauri::command]async fn fetch_status(url: String) -> Result<u16, String> { let res = tauri_plugin_http::reqwest::get(&url) .await .map_err(|e| e.to_string())?; Ok(res.status().as_u16())}
pub fn configure<R: tauri::Runtime>(builder: tauri::Builder<R>) -> tauri::Builder<R> { builder .plugin(tauri_plugin_opener::init()) .plugin(tauri_plugin_http::init()) .invoke_handler(tauri::generate_handler![greet]) .invoke_handler(tauri::generate_handler![greet, fetch_status])}
#[cfg_attr(mobile, tauri::mobile_entry_point)]Default Permission
This permission set configures what kind of fetch operations are available from the http plugin.
This enables all fetch operations but does not allow explicitly any origins to be fetched. This needs to be manually configured before usage.
Granted Permissions
All fetch operations are enabled.
This default permission set includes the following:
allow-fetchallow-fetch-cancelallow-fetch-sendallow-fetch-read-bodyallow-fetch-cancel-body
Permission Table
| Identifier | Description |
|---|---|
|
|
Enables the fetch command without any pre-configured scope. |
|
|
Denies the fetch command without any pre-configured scope. |
|
|
Enables the fetch_cancel command without any pre-configured scope. |
|
|
Denies the fetch_cancel command without any pre-configured scope. |
|
|
Enables the fetch_cancel_body command without any pre-configured scope. |
|
|
Denies the fetch_cancel_body command without any pre-configured scope. |
|
|
Enables the fetch_read_body command without any pre-configured scope. |
|
|
Denies the fetch_read_body command without any pre-configured scope. |
|
|
Enables the fetch_send command without any pre-configured scope. |
|
|
Denies the fetch_send command without any pre-configured scope. |
© 2026 Tauri Contributors. CC-BY / MIT