> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes. # Chat.Client You can use the Client object to build a messaging system into the browser. Example usage: ```js import { Chat } from "@signalwire/js"; const chatClient = new Chat.Client({ token: "", // get this from the REST APIs }); await chatClient.subscribe(["mychannel1", "mychannel2"]); chatClient.on("message", (message) => { // prettier-ignore console.log("Received", message.content, "on", message.channel, "at", message.publishedAt); }); await chatClient.publish({ channel: "mychannel1", content: "hello world", }); ``` ## Constructors ### constructor * **new Client**(`chatOptions`) Creates a new Chat client. #### Parameters **`chatOptions`** `object` — required Configuration options for the Chat client --- **`chatOptions.token`** `string` — required SignalWire Chat token that can be obtained from the [REST APIs](/docs/apis/rest/chat-tokens/create-chat-token). --- #### Example ```js import { Chat } from "@signalwire/js"; const chatClient = new Chat.Client({ token: "", }); ``` --- ## Type Aliases ### PaginationCursor This is a utility object that aids in pagination. It is specifically used in conjunction with the [getMessages](/docs/browser-sdk/v3/js/reference/chat/client/get-messages) method. #### Properties **`after`** `string` This property signifies the cursor for the subsequent page. --- **`before`** `string` This property signifies the cursor for the preceding page. --- ## Docs - [Events](https://signalwire.com/docs/browser-sdk/v3/js/reference/chat/client/events.md) - [disconnect](https://signalwire.com/docs/browser-sdk/v3/js/reference/chat/client/disconnect.md) - [getAllowedChannels](https://signalwire.com/docs/browser-sdk/v3/js/reference/chat/client/get-allowed-channels.md) - [getMembers](https://signalwire.com/docs/browser-sdk/v3/js/reference/chat/client/get-members.md) - [getMemberState](https://signalwire.com/docs/browser-sdk/v3/js/reference/chat/client/get-member-state.md) - [getMessages](https://signalwire.com/docs/browser-sdk/v3/js/reference/chat/client/get-messages.md) - [off](https://signalwire.com/docs/browser-sdk/v3/js/reference/chat/client/off.md) - [on](https://signalwire.com/docs/browser-sdk/v3/js/reference/chat/client/on.md) - [once](https://signalwire.com/docs/browser-sdk/v3/js/reference/chat/client/once.md) - [publish](https://signalwire.com/docs/browser-sdk/v3/js/reference/chat/client/publish.md) - [removeAllListeners](https://signalwire.com/docs/browser-sdk/v3/js/reference/chat/client/remove-all-listeners.md) - [setMemberState](https://signalwire.com/docs/browser-sdk/v3/js/reference/chat/client/set-member-state.md) - [subscribe](https://signalwire.com/docs/browser-sdk/v3/js/reference/chat/client/subscribe.md) - [unsubscribe](https://signalwire.com/docs/browser-sdk/v3/js/reference/chat/client/unsubscribe.md) - [updateToken](https://signalwire.com/docs/browser-sdk/v3/js/reference/chat/client/update-token.md)