drift Docs
Start
What is Drift?
The tour, if you are new here.
Use cases
Whether Drift does your thing.
Getting started
Nothing to deployed, in one command.
Architecture
How a slice is put together.
What it costs
The free grant, four unit prices, two rules.
Build
Canvas
Static sites, same origin as your API.
Tools
Operate
Auth
Accounts, tokens and scopes.
Security
Boundaries, sandboxing and hardening.
Troubleshooting
Error codes
What went wrong, and what to do about it.
Legal
Acceptable use
What a slice may not be used for.
Data processing
The DPA, and every sub-processor.

Realtime

drift.Backbone.Realtime.Channel(name): in-slice pub/sub, from the server side.

Signatures

Go
Publish(msg any) (int, error)   // → recipient count   ·   Presence() (int, error)   // → connected count

Both return a count, which is the useful part: Publish tells you how many sockets actually received the message, so a fan-out to nobody is visible rather than silent.

Browsers subscribe directly

The SDK is only the server half. A browser joins a channel over WebSocket at /realtime/<channel>, same-origin with your Canvas site, so there is no cross-origin handshake and no broker to run.

A channel has no authentication and no authorization.

Anyone who can reach your slice's URL and knows or guesses a channel name can subscribe to it and broadcast to everyone on it. Put nothing on a channel you would not hand to an anonymous caller, and keep the privileged half behind a function. The Backbone guide has the connection caps and what happens past them.

To stream a response from a single function call rather than to a shared channel, add stream=sse or stream=ws to the function; see Writing a handler.