Documentation
Sign inGet started

Public channels

A channel is public when its name does not start with private- or presence-. Any client holding the app key can subscribe to it, and the app key ships in your client code, so treat a public channel as readable by anyone who can open your site.
代码示例
const orders = bird.subscribe("orders");
orders.bind("order-updated", (data) => {
  console.log(data);
});
There is nothing to create or configure. The channel exists while at least one connection is subscribed and disappears when the last one leaves.

When to use one

Use a public channel for data that is already public, or that is harmless to expose: build status, a live scoreboard, flight information, the number of people viewing a page, a status-page incident feed.
Do not use one for anything scoped to a user or a tenant. If the data belongs to one account, the channel name is not a secret and guessing it is trivial. Use a private channel instead.

What public channels cannot do

  • No member identity. Public channels have no members, so no bird:member_added or bird:member_removed events and no member list. Those belong to presence channels.
  • No client events. A client cannot send client- events on a public channel. The edge rejects them with Client event rejected - only supported on private and presence channels.
Connection counting works on any channel type. When the app has it enabled, the client receives bird:connection_count with the number of connections currently subscribed.

Naming

Channel names allow letters, digits, and _ - = @ , . ; up to 164 characters. Names are case-sensitive and matched exactly, so Orders and orders are two channels.
Because a public channel name is visible to every client, keep identifiers out of it that you would not want enumerated. orders is fine. orders-user-4821 is a public channel whose name tells anyone that user 4821 exists.

Next steps