Using the Realtime API you can create channels and channel resources where messages can be published. Site visitors who subscribe to a channel receive the published messages published to that channel. When a message is received you can handle the message any way you choose, such as displaying the contents of the message or changing the state of page elements depending on the contents of the message. You can also manage the permissions of who can read from specific channels.
wix-realtime-backend module is used in conjunction with the
Typical uses of the Realtime API include implementing a messaging system or as an alternative to using a polling mechanism.
The Realtime API uses the following terminology:
- Channel: A specific channel on which messages are published. Each channel has a unique name. Site visitors can subscribe to a channel to receive the messages that are published on it. When site visitors subscribe to a channel, they do not receive messages published to a resource on that same channel.
- Channel resource: A subchannel on which messages are published. Subchannels can share a name with a channel and other subchannels, but they have a unique resource ID. When site visitors subscribe to a channel resource, they do not receive messages published to that same channel without a specified resource. Channel resources inherit their parent channel's permissions, unless specified otherwise.
- Message: A message published on a channel or channel resource. A message can be of any type, such as a string, number, or object. Channel subscribers receive the messages published on the channel.
- Publish: Sending a message over a channel or channel resource.
- Subscribe: A site visitor subscribes to receive the messages published on a channel or channel resource.
- Permissions router: The permissions router is used to define the permissions you want to grant to subscribers on channels and channel resources.
- Permissions handler: Handles a permissions check for a specific user on a specific channel or channel resource.
To use the Realtime API in the backend, import
wixRealtimeBackend from the
Was this helpful?