# Private channels and live chat without a backend

> For Webflow, Framer, static sites and Supabase or Firebase apps: private notifications, live chat and an online list, through a ready-made Cloudflare Worker that checks the login you already have.

Source: https://hibira.io/use-cases/realtime-without-backend

Plenty of sites have no backend of their own: a Webflow or Framer page, a static site, a Jamstack shop, or a mobile app that signs in with Supabase or Firebase. Public channels work there, but anything only one person should see, or anything a visitor sends, needs a server that knows who they are and holds your app secret. Writing and hosting that server just for realtime is usually what stops the feature. Our ready-made Cloudflare Worker is that server: you deploy it to your own Cloudflare account in one click, it checks the login you already have, and your page talks to it directly.

## What your users get

- Notifications only they can see: "your order shipped", "someone replied to you", the moment it happens.
- A live chat or Q&A next to a livestream, with the list of who's here.
- "Kai is typing…" and other small live hints between visitors.
- The same features in your mobile app, signed in with the account they already use.

![A live tasting on a static page: messages go through the Worker's /publish, and "Kai is typing…" is a client event. Both views are connected to the same channel.](https://hibira.io/portal/articles/demo-realtime-without-backend-en.webp)

## Who it helps

| You have | What stops you today | With the Worker |
| --- | --- | --- |
| A Webflow, Framer or static site with members | Private channels need a backend to sign them | One-click deploy; it checks your members' login token and signs only their own channels |
| An app on Supabase or Firebase | Another server to run just for realtime | It reads the Supabase or Firebase token as it is; you write no server code |
| A team tool or dashboard per company | Each company must see only its own channels | A rule such as `private-org-{org_id}-*` lets people in by the company in their token |
| An internal dashboard behind Cloudflare Access | Wiring staff logins to channel auth | Access sends the token itself, so the page needs no changes |
| A party game, poll or event room with no accounts | Players still need a name and an online list | Guest mode gives each visitor a `guest-` ID and a name |
| Any page using pusher-js | The app secret must never be in the browser | The secret stays in Cloudflare as a Worker secret |

## Step 1: deploy the Worker

Press [Deploy to Cloudflare](https://deploy.workers.cloudflare.com/?url=https://github.com/hibira-io/cloudflare/tree/main/channel-auth) and enter your app key and secret, your login's public keys and which channels a user may join. Open the Worker's address afterwards: its setup page shows whether anything is missing.

```text
HIBIRA_KEY      your app key
HIBIRA_SECRET   your app secret (stored as a secret)
JWKS_URL        https://YOUR-APP.clerk.accounts.dev/.well-known/jwks.json
CHANNELS        private-user-{id},presence-*
PUBLISH         presence-room-*
PUBLISH_EVENTS  message
HIBIRA_APP_ID   your app ID
```

## Step 2: point your page at it

```js
const auth = 'https://hibira-channel-auth.YOUR-SUBDOMAIN.workers.dev';
const headersProvider = () => ({ Authorization: `Bearer ${getToken()}` });

const pusher = new Pusher('YOUR_APP_KEY', {
  cluster: 'hkg',
  wsHost: 'ws.hibira.io',
  forceTLS: true,
  enabledTransports: ['ws', 'wss'],
  channelAuthorization: { endpoint: `${auth}/pusher/auth`, headersProvider },
});

pusher.subscribe(`private-user-${userId}`).bind('order.shipped', showToast);
```

`getToken()` returns your login's current token, such as `await clerk.session.getToken()` or the Supabase session's `access_token`.

## Step 3: send messages

Subscribing needs no backend now, and neither does sending. Pick the way that fits what you send:

| Way | Good for | What checks the sender |
| --- | --- | --- |
| Client events | Typing hints, live cursors, "seen" marks, game moves | Hibira: only on private and presence channels the Worker signed |
| The Worker's `/publish` | Chat messages, comments, votes, reactions | The Worker: the login token and your `PUBLISH` rules |
| Your database or a no-code tool | Order status, new rows, form entries | That tool, which keeps your app secret |

**Client events** go straight from one browser to the others on the channel. Turn on Client events in your app's settings first. Nothing checks what they say, so keep them for things that are fine to miss.

```js
const room = pusher.subscribe('presence-room-1');
room.trigger('client-typing', { name: 'Mei' });
room.bind('client-typing', (data) => showTyping(data.name));
```

**The Worker's `/publish`** is for messages that need to be trusted. The Worker checks the login token and your rules, then fills in `data.sender` from the token, so nobody can post as someone else.

```js
await fetch(`${auth}/publish`, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json', ...headersProvider() },
  body: JSON.stringify({ channel: 'presence-room-1', event: 'message', data: { text: 'Hello' } }),
});

room.bind('message', ({ text, sender }) => addMessage(sender.name, text));
```

**From your data.** When a message starts with a change in your data, such as an order that ships, send it from where that change happens: a Supabase Edge Function or Firebase Cloud Function with a Pusher server library, or the Hibira nodes for [n8n](https://hibira.io/guides/n8n), [Make](https://hibira.io/guides/make), [Activepieces](https://hibira.io/guides/activepieces) and [Node-RED](https://hibira.io/guides/node-red). See the [Supabase guide](https://hibira.io/guides/supabase) for a full example.

## Tips

- Each user may send 20 messages a minute through `/publish`; change it in the Worker's `wrangler.jsonc`.
- With guest mode on, guests can send too, but only to the channels your rules allow, and always as `guest-` IDs.
- The Workers free plan covers 100,000 requests a day. Each subscription to a private or presence channel and each `/publish` is one request; messages count against your Hibira plan as usual.
- Want typing hints and an online list in a full chat? See [chat with typing indicators](https://hibira.io/use-cases/chat-typing-indicators). The [Cloudflare Workers guide](https://hibira.io/guides/cloudflare) lists every setting.
