You can use the Client object to build a messaging system into the browser. Example usage: js import { 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](/rest/signalwire-rest/endpoints/chat/chat-tokens-create). | #### Example js import { PubSub } from @signalwire/js; const pubSubClient = new PubSub.Client({ token: }); ## Methods ### disconnect ▸ **disconnect**(): void Disconnects this client. The client will stop receiving events and you will need to create a new instance if you want to use it again. #### Returns void #### Example js client.disconnect(); ### getAllowedChannels ▸ **getAllowedChannels**(): Promise