*** id: dd948bdb-ed60-4c51-b052-a2bce5b3b8f4 title: subscribe slug: /node/reference/pubsub/client/subscribe description: subscribe method for the Client class. max-toc-depth: 3 ---------------- [pubsub-client]: /docs/server-sdk/v3/node/reference/pubsub/client/unsubscribe ### subscribe * **subscribe**(`channels`): `Promise` List of channels for which you want to receive messages. 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][pubsub-client]. #### Parameters | Name | Type | Description | | :--------- | :--------------------- | :----------------------------------------------------------------------------------------------------- | | `channels` | `string` \| `string[]` | The channels to subscribe to, either in the form of a string (for one channel) or an array of strings. | #### Returns `Promise` #### Example ```js const pubSubClient = new PubSub.Client({ project: "", token: "", }); await pubSubClient.subscribe("my-channel"); await pubSubClient.subscribe(["chan-2", "chan-3"]); ```