publish( )

Publishes a message to a channel or channel resource.

The publish() function publishes a message to the specified channel or channel resource.

When site visitors subscribe to a channel, they do not receive messages published to a resource on that same channel. Similarly, when site visitors subscribe to a channel resource, they do not receive messages published to that same channel without a specified resource.

To publish a message to specific users only, specify the users by ID in the PublishOptions object sent to the options parameter.

To include the ID of the user who triggered the publish in the published message, set the includePublisher property of the PublishOptions object to true.

Method Declaration
Method Parameters

The channel, and optionally the resource, to publish to.


Message payload. Max: 10kb


Options to use when publishing.

Return Type:Promise<void> | void
Was this helpful?