> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hop.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Updating Channel State

> How to update Hop Channel state

[Channel State](./channel-state) acts as a realtime data store attached
to every Channel. You can update this state on your backend and frontend clients
can subscribe to Channel state objects in realtime.

<Info>
  This reference assumes you have already set up the [Hop server-side
  SDK](/sdks/server/js).
</Info>

## Updating State

Channel state can be updated (manually) through the Hop Console or
(programatically) through our server-side SDKs.

```js updating-state.js theme={null}
// Import your Hop SDK instance
import {hop} from '.';

const channelId = 'channel_xxx'; // the channel we want to update

/*
 * - Option 1: Rewrite the state.
 * - The existing state is passed as the first arument to Channel#setState
 */

hop.channels.setState(channelId, s => ({...s, name: 'My Channel'}));

/*
 * - Option 2: Update or add variables
 * - This operation will only effect the variables you specify.
 * - The rest of the state will remain unchanged
 */

channel.patchState(channelId, {name: 'My Channel'});
```

Either of these operations will update the connected clients in realtime.
