Raw bindings to the Tauri API
for projects using wasm-bindgen
This crate is not yet published to crates.io, so you need to use it from git. You also need a global installation of esbuild
.
tauri-sys = { git = "https://github.com/JonasKruckenberg/tauri-sys" } // Tauri v1
// OR
tauri-sys = { git = "https://github.com/JonasKruckenberg/tauri-sys", branch = "v2" } // Tauri v2
use serde::{Deserialize, Serialize};
use tauri_sys::tauri;
#[derive(Serialize, Deserialize)]
struct GreetArgs<'a> {
name: &'a str,
}
fn main() {
wasm_bindgen_futures::spawn_local(async move {
let new_msg: String = tauri::invoke("greet", &GreetArgs { name: &name.get() }).await.unwrap();
println!("{}", new_msg);
});
}
All modules are gated by accordingly named Cargo features. It is recommended you keep this synced with the features enabled in your Tauri Allowlist but no automated tool for this exists (yet).
- all: Enables all modules.
- app: Enables the
app
module. - clipboard: Enables the
clipboard
module. - dialog: Enables the
dialog
module. - event: Enables the
event
module. - fs: Enables the
fs
module. - mocks: Enables the
mocks
module. - tauri: Enables the
tauri
module.
These API bindings are not completely on-par with @tauri-apps/api
yet, but here is the current status-quo:
-
app
-
cli
-
clipboard
-
dialog
-
event
-
fs
-
global_shortcut
-
http
-
mocks
-
notification
-
os
-
path
-
process
-
shell
-
tauri
-
updater
-
window
The current API also very closely mirrors the JS API even though that might not be the most ergonomic choice, ideas for improving the API with quality-of-life features beyond the regular JS API interface are very welcome.