*** id: 49dc51c9-f728-4327-a8bb-3bbc8bbd3ec9 title: setMemberState slug: /node/reference/chat/client/set-member-state description: setMemberState method for the Client class. max-toc-depth: 3 ---------------- ### setMemberState * **setMemberState**(`params`): `Promise` Sets a state object for a member, for the specified channels. The previous state object will be completely replaced. #### Parameters Object containing the parameters of the method. Channels for which to set the state. Id of the member to affect. The state to set. There are no requirements on the content of the state. #### Returns `Promise` #### Example In this example, we set the state of the member `User1` in the channel `channel1` to `{ online: true, typing: false }`. We then fetch the state of the member and print it to the console. ```js import { SignalWire } from "@signalwire/realtime-api"; const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" }) const chatClient = client.chat; let usesId = 'User1'; // Assumes a member with this id already exists and has joined the channel. // set the member state await chatClient.setMemberState({ memberId: usesId, channels: "channel1", // or a list of channels like: ["channel1", "channel2"] state: { online: true, typing: false, } }); // get the member state const s = await chatClient.getMemberState({ channels: "channel1", // or a list of channels like: ["channel1", "channel2"] memberId: usesId, }); // print the state console.log(`The state of ${usesId} is: ${JSON.stringify(s.channels.channel1.state, null, 2)}`); ```