Getting started

Installation

Add the Rust crate and the npm package, register the plugin and allow its commands.

Automatic

The Tauri CLI adds the crate and the npm package and registers the plugin:

npm run tauri add centrifugo
# or: pnpm tauri add centrifugo · yarn run tauri add centrifugo · bun tauri add centrifugo
# or: deno task tauri add centrifugo · cargo tauri add centrifugo

Then check that your capability has centrifugo:default (see Permissions).

Manual

Rust

cd src-tauri
cargo add tauri-plugin-centrifugo

Register the plugin:

src-tauri/src/lib.rs
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
    tauri::Builder::default()
        .plugin(tauri_plugin_centrifugo::init())
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

JavaScript

npm install tauri-plugin-centrifugo-api
# or
pnpm add tauri-plugin-centrifugo-api

The package is ESM and CJS with types; its only dependency is @tauri-apps/api 2.

Permissions

Plugin commands are denied until a capability allows them. centrifugo:default allows every command:

src-tauri/capabilities/default.json
{
  "identifier": "default",
  "windows": ["main"],
  "permissions": ["core:default", "centrifugo:default"]
}

To allow only some commands, list centrifugo:allow-<command> identifiers instead; see the Permissions guide and the full list.

Requirements

  • Tauri 2 (the crate needs tauri 2.6.2+), Rust 1.85+.
  • A Centrifugo v4+ server; see Centrifugo server.