*** id: 30ed88d1-e508-4135-8eea-1095ebf92022 title: PubSub sidebar-title: Overview position: 0 keywords: 'SignalWire, Realtime SDK, Node.js, PubSub, publish subscribe, real-time events' slug: /node/reference/pubsub description: >- Access the PubSub API for publish-subscribe messaging patterns. Subscribe to channels, publish messages, and build real-time event-driven applications. max-toc-depth: 3 ---------------- [pubsub-client-1]: /docs/server-sdk/v4/node/reference/pubsub/client [pubsub-client]: /docs/server-sdk/v4/node/reference/pubsub/client#events Access the PubSub API Consumer. You can instantiate a [PubSub.Client][pubsub-client-1] to subscribe to PubSub events. Refer to [PubSub Events][pubsub-client] for the full list of events that a [PubSub.Client][pubsub-client-1] can subscribe to. #### Example The following example logs the messages sent to the "welcome" channel. ```javascript import { SignalWire} from "@signalwire/realtime-api"; const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" }) const pubSubClient = client.pubSub; await pubSubClient.listen({ channels: ["welcome"], onMessageReceived: (message) => { console.log("Received message:", message); } }); ``` ## **Classes** The main PubSub client for publishing messages and subscribing to channels. Represents a message received on a PubSub channel with content and metadata.