tauri-plugin-tauribun

Crates.iotauri-plugin-tauribun
lib.rstauri-plugin-tauribun
version0.1.0
created_at2026-01-24 00:08:47.347326+00
updated_at2026-01-24 00:08:47.347326+00
descriptionTauri plugin for managing Bun sidecars with oRPC communication
homepagehttps://github.com/lott-ai/tauribun
repositoryhttps://github.com/lott-ai/tauribun
max_upload_size
id2065743
size157,936
Chris Lott (lott-ai)

documentation

README

Tauri Plugin Tauribun

A Tauri v2 plugin for managing Bun sidecars with type-safe oRPC communication.

Installation

Rust

Add the plugin to your Tauri app's Cargo.toml:

[dependencies]
tauri-plugin-bun = { path = "path/to/tauri-plugin-bun" }

Register the plugin in your lib.rs:

tauri::Builder::default()
    .plugin(tauri_plugin_tauribun::init())

JavaScript

Add the plugin API to your frontend:

bun add tauri-plugin-tauribun

Capabilities

Add the plugin permissions to your capabilities file:

{
  "permissions": [
    "tauribun:default"
  ]
}

Usage

Server (Bun Sidecar)

Define your RPC procedures and call createServer() to start the server:

// main.ts (sidecar entry point)
import { createServer, os } from 'tauri-plugin-tauribun';
import * as z from "zod";

const router = {
  ping: os
    .route({
      method: "POST",
      path: "/",
      summary: "Ping-pong",
    })
    .input(z.object({ message: z.string() }))
    .output(z.object({ message: z.string() }))
    .handler(async ({ input }) => {
      console.log("Received:", input.message);
      return { message: "Pong!" };
    }),
};

createServer('my-server', router);

export type Router = typeof router;

Client (Frontend)

Use createClient() or createQueryClient() for TanStack Query integration:

// lib/orpc.ts
import { createQueryClient } from 'tauri-plugin-tauribun';
import type { Router } from './server';

export const orpc = createQueryClient<Router>('my-server');
// In a React component
import { useMutation } from '@tanstack/react-query';
import { orpc } from './lib/orpc';

function PingButton() {
  const { mutate } = useMutation(
    orpc.ping.mutationOptions({
      onSuccess: (data) => console.log(data.message),
    })
  );

  return (
    <button onClick={() => mutate({ message: "Hello!" })}>
      Ping
    </button>
  );
}

Direct Client Usage

For non-React Query usage:

import { createClient } from 'tauri-plugin-tauribun';
import type { Router } from './server';

const client = createClient<Router>('my-server');

const response = await client.ping({ message: "Hello, world!" });
console.log(response.message); // "Pong!"

API Reference

createServer(name, router)

Creates an oRPC server in the Bun sidecar.

  • name: Identifier for the server (used for logging)
  • router: oRPC router object with your procedures

createClient<T>(name, options?)

Creates an oRPC client connected to a sidecar.

  • name: Server name to connect to
  • options.binaryPath: Path to sidecar binary (default: "binaries/bun")

createQueryClient<T>(name, options?)

Creates a TanStack Query-enabled oRPC client.

disconnectClient(name)

Disconnects and cleans up a client connection.

Architecture

Frontend (WebView)
    └─> createClient('my-server')
        └─> Tauri Plugin (Rust)
            └─> Spawn/manage sidecar process
                └─> Bun Sidecar running createServer('my-server', router)

Communication happens via stdio using oRPC's stdio adapter.

Commit count: 10

cargo fmt