Integrations
Tauri

Tauri

rspc has a built-in integration with Tauri (opens in a new tab) so that you can expose your API to your frontend code using Tauri's IPC.

Enable feature

For the integration to work you must enable the tauri feature of rspc. Ensure the rspc line in your Cargo.toml file looks like the following:

Cargo.toml
[dependencies]
rspc = "0.0.0"
rspc_tauri = "0.0.0"

Read more about Rust features here (opens in a new tab)

Usage

Then expose your router using the Tauri plugin.

src/main.rs
let router = <Router>::new().build();
 
tauri::Builder::default()
    .plugin(rspc_tauri::plugin(router.arced(), |app_handle| ()))

Usage on frontend

index.ts
import { createClient } from "@rspc/client";
import { TauriTransport } from "@rspc/tauri";
import type { Procedures } from "./ts/bindings"; // These were the bindings exported from your Rust code!
 
const client = createClient<Procedures>({
  transport: new TauriTransport(),
});
 
client.query(["version"]).then((data) => console.log(data));

You can use the client by itself or integrate with the Tanstack Query hooks.