# Realtime, waiting rooms and chat for Axum and Actix Web

> The Hibira crate publishes events, signs channel subscriptions and webhooks, puts a waiting room in front of Axum or Actix Web routes, and calls the Chat API and Approvals.

Source: https://hibira.io/guides/rust

The Hibira crate publishes events, signs channel subscriptions and webhooks, puts a waiting room in front of Axum or Actix Web routes, and calls the Chat API and Approvals.

Package: hibira

- Waiting room middleware for Axum and Actix Web; the handler receives the visitor’s pass.
- Channel auth for private and presence channels, pusher-js sign-in and webhook checks, with no network code when the client feature is off.
- Chat API, Approvals and Live Chat verified visitors from the same crate.

## 1. Install

```shell
cargo add hibira --features axum   # or --features actix
```

## 2. Set it up

```shell
HIBIRA_APP_ID=YOUR_APP_ID
HIBIRA_KEY=YOUR_APP_KEY
HIBIRA_SECRET=YOUR_APP_SECRET
HIBIRA_HOST=ws.hibira.io
```

## 3. Use it

```rust
use std::sync::Arc;
use axum::{middleware, routing::get, Extension, Router};
use hibira::{waiting_room::axum_guard, Client, Config, Pass};

let config = Config::from_env()?;
let hibira = Client::new(config.clone());
hibira.trigger(&["orders"], "order.shipped", &serde_json::json!({ "id": 1042 })).await?;

let app = Router::new()
    .route("/drop", get(|Extension(pass): Extension<Pass>| async move { format!("You are number {}", pass.number) }))
    .layer(middleware::from_fn_with_state(Arc::new(config.waiting_room("presale")), axum_guard));
```

## Before you start

- The app secret is shown only once, when you create the app or rotate its secret. Keep it on your server, never in a browser or game build.
- Private and presence channels need an auth endpoint on your backend that signs subscriptions with the app secret, as with pusher-js.

- [crates.io](https://crates.io/crates/hibira)
- [GitHub](https://github.com/hibira-io/rust)
