tauri-plugin-axum
Call your Axum router directly — just like a local database, not a remote server.
Features
-
Custom protocol registration
// Important: if you use a custom protocol, register it *before* the setup hook. // https://docs.rs/tauri/2.8.2/tauri/plugin/struct.Builder.html#known-limitations default.plugin
Once registered, you can access your Axum routes via:
- macOS, iOS, and Linux:
axum://localhost/<path> - Windows and Android:
http://axum.localhost/<path>(default)
Note: Custom protocols currently do not support streaming. (#1404)
-
stream body support
Supports streaming responses using either the provided fetch API or an Axios adapter:
import { fetch } from "tauri-plugin-axum-api/fetch"; import { Adapter } from "tauri-plugin-axum-api/axios";
Installation
Automatic
or Manual
Rust crate:
npm package:
Add required capability in src-tauri/capabilities/default.json:
{
// ...
"permissions": ["axum:default"],
// ...
}
Usage Example
// URI scheme protocols are registered when the WebView is created.
// If the plugin is registered after a WebView has been created,
// the protocol will not be available.
//
// macOS, iOS, Linux: axum://localhost/<path>
// Windows, Android: http://axum.localhost/<path> (default)
default.plugin;
window.fetch("http://axum.localhost/");
import { fetch } from "tauri-plugin-axum-api/fetch";
fetch("/", { method: "GET" })
.then((res) => res.text())
.then((res) => console.log(res));
// Using Axios adapter
import axios from "axios";
import { Adapter } from "tauri-plugin-axum-api/axios";
const instance = axios.create({ adapter: Adapter });
Example Project
Run Example