---title: PubSub.Clientsidebar_label: Clientsidebar_position: 0---import MethodOff from ../../_common/_method_off.mdx;import MethodOn from ../../_common/_method_on.mdx;import MethodOnce from ../../_common/_method_once.mdx;import MethodRemoveAllListeners from ../../_common/_method_removealllisteners.mdx;You can use the Client object to build a messaging system into the browser.Example usage:jsimport { PubSub } from @signalwire/js;const pubSubClient = new PubSub.Client({ token: , // get this from the REST APIs});await pubSubClient.subscribe([mychannel1, mychannel2]);pubSubClient.on(message, (message) => { // prettier-ignore console.log(Received, message.content, on, message.channel, at, message.publishedAt);});await pubSubClient.publish({ channel: mychannel1, content: hello world,});## Constructors### constructor• **new Client**(pubSubOptions)Creates a new PubSub client.#### Parameters| Name | Type | Description || :-------------------- | :------- | :----------------------------------------------------------------------------------------------------------- || pubSubOptions | Object | - || pubSubOptions.token | string | SignalWire Chat token that can be obtained from the [REST APIs](pathname:///rest/generate-a-new-chat-token). |#### Examplejsimport { PubSub } from @signalwire/js;const pubSubClient = new PubSub.Client({ token: ,});## Methods### disconnect▸ **disconnect**(): voidDisconnects this client. The client will stop receiving events and you will need to create a new instance if you want to use it again.#### Returnsvoid#### Examplejsclient.disconnect();---### getAllowedChannels▸ **getAllowedChannels**(): Promise