3 releases

0.2.2 Jan 29, 2025
0.2.1 Jan 29, 2025
0.2.0 Jan 29, 2025

#2166 in Web programming

50 downloads per month

MIT license

77KB
1K SLoC

Logo

rspc

A blazing fast and easy to use TRPC-like server for Rust.

Website



[!WARNING] rspc is no longer being maintained. Learn more.

Example

You define a rspc router and attach procedures to it like below. This will be very familiar if you have used trpc or GraphQL before.

let router = <rspc::Router>::new()
    .query("version", |t| {
        t(|ctx, input: ()| "0.0.1")
    })
    .mutation("helloWorld", |t| {
        t(|ctx, input: ()| async { "Hello World!" })
    });

Features:

  • Per Request Context - Great for database connection & authentication data
  • Middleware - With support for context switching
  • Merging routers - Great for separating code between files

Inspiration

This project is based off trpc and was inspired by the bridge system Jamie Pine designed for Spacedrive. A huge thanks to everyone who helped inspire this project!


lib.rs:

Tauri integration for rspc.

Example

use rspc::Router;

let router = Router::new();
let (procedures, _types) = router.build().unwrap();

tauri::Builder::default()
    .plugin(tauri_plugin_rspc::init(procedures, |window| todo!()))
    .run(tauri::generate_context!())
    .expect("error while running tauri application");

Dependencies

~18–54MB
~867K SLoC