Tauri Plugin Centrifugo
Real-time messaging with a Centrifugo server for Tauri 2 apps on
desktop, Android and iOS, built on the official Rust SDK
centrifuge-client.
Documentation: https://s00d.github.io/tauri-plugin-centrifugo/
- Real networks: reconnects with backoff, ping/pong liveness, wake-from-sleep detection, OS proxy settings and trust store (from the SDK).
- Transports: WebSocket with JSON or Protobuf, optional HTTP-streaming fallback, custom headers.
- Recovery: recoverable/positioned subscriptions, resume from a saved stream position, fossil delta compression.
- Tokens: connection and subscription JWTs, refreshed before expiry by asking your frontend.
- Operations: publish, RPC, send, history, presence, presence stats; base64 or raw JSON payloads.
| Platform | Supported |
|---|---|
| Windows · macOS · Linux | ✅ |
| Android | ✅ (TLS with Mozilla roots via webpki-roots; user-installed CAs are not trusted) |
| iOS | ✅ |
Server: Centrifugo v4+ (client protocol v2); HTTP streaming needs v5+ with http_stream enabled.
Tested against Centrifugo v5.4.9.
Install
or by hand:
Register the plugin and allow it in a capability:
// src-tauri/src/lib.rs
default
.plugin
.run
.expect;
// src-tauri/capabilities/default.json
{ "identifier": "default", "windows": ["main"], "permissions": ["core:default", "centrifugo:default"] }
Quick start
import { connect, onConnected, onPublication, helpers, utils } from "tauri-plugin-centrifugo-api";
await onConnected(({ payload }) => console.log("connected, client", payload.client));
await onPublication(({ payload }) => console.log(payload.channel, payload.rawJson ?? utils.decode(payload.data)));
await connect({
url: "ws://localhost:8000/connection/websocket",
token: "<connection JWT>", // optional; or requestToken: true + onNeedToken/provideToken
channels: ["news"],
useProtobuf: false,
});
if (await helpers.waitForConnection()) {
await helpers.publishJson("news", { text: "hello" });
}
Documentation
| Getting started | Install, permissions, quick start, example app |
| Connection & config | Every connect() option, transports, state, errors |
| Events | Every centrifugo:* event and its payload |
| Subscriptions | Recovery, since, delta, join/leave |
| Tokens | token vs requestToken, need_token / provideToken, need_sub_token / subRefresh |
| Rust backend | The plugin's client and the SDK from Rust · docs.rs |
| Platforms | Desktop, Android TLS, iOS, Centrifugo versions |
| API reference | Generated from the sources: functions, types, Tauri commands, permissions |
| Deprecations | ping, map publish, track/untrack |
| Changelog |
Example app
examples/tauri-app is a Vue app for desktop and mobile;
examples/server has a Centrifugo config for it:
&& &&
Development
&& && && && &&
CI runs all of it on Linux, macOS and Windows against Centrifugo v5.4.9, and builds for Android; cargo-mutants runs only locally.
License
MIT, see LICENSE. If the plugin helps you, you can support it via DonationAlerts.