WARNING: These docs are a work in progress! Some sections are incomplete or incorrect.

Tauri

rspc has a built-in integration with Tauri 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:

[dependencies]
rspc = "0.0.0"
rspc-tauri = "0.0.0"

Read more about Rust features here

Usage

Then expose your router using the Tauri plugin.

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

Usage on frontend

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.

Edit on GitHub

Last updated on

On this page