For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Log inSign up
Support
ReferenceGuidesClick-to-Call
ReferenceGuidesClick-to-Call
  • Core
    • Overview
  • SignalWire Client
    • Overview
    • Notifications
    • Client
    • Utility functions
  • Video
    • Overview
    • LocalOverlay
    • RoomSession
    • RoomSessionDevice
    • RoomSessionPlayback
    • RoomSessionRecording
    • RoomSessionScreenShare
    • RoomSessionStream
    • RoomDevice
    • RoomScreenShare
  • Chat
    • Overview
    • Client
    • ChatMember
    • ChatMemberEntity
    • ChatMessage
    • ChatMessageEntity
  • PubSub
    • Overview
    • Client
      • Events
        • disconnect
        • getAllowedChannels
        • off
        • on
        • once
        • publish
        • removeAllListeners
        • subscribe
        • unsubscribe
        • updateToken
    • PubSubMessage
  • WebRTC
    • Overview
LogoLogoSignalWire Docs
Log inSign up
Support
On this page
  • subscribe
PubSubClientMethods

subscribe

|View as Markdown|Open in Claude|
Was this page helpful?
Edit this page
Previous

unsubscribe

Next
Built with

subscribe

  • subscribe(channels): Promise<void>

List of channels for which you want to receive messages. You can only subscribe to those channels for which your token has read permission.

Note that the subscribe function is idempotent, and calling it again with a different set of channels will not unsubscribe you from the old ones. To unsubscribe, use unsubscribe.

Parameters

channels
string | string[]Required

The channels to subscribe to, either in the form of a string (for one channel) or an array of strings.

Returns

Promise<void>

Example

1const pubSub = new PubSub.Client({
2 token: "<your chat token>"
3});
4
5pubSub.on("message", (m) => console.log(m));
6
7await pubSub.subscribe("my-channel");
8await pubSub.subscribe(["chan-2", "chan-3"]);