# RoomClient: state property

> The state read-only property of the RoomClient interface is the room's shared state, which every connection sees.

The **`state`** read-only property of the [`RoomClient`](/docs/client/room-client) interface is the room's shared state: the one entity of the schema's `state` kind that every connection sees.

## Value

A [`ClientEntity`](/docs/client/client-entity) of the schema's `state` kind, with its fields as read-only properties, or `undefined` until [`ready`](/docs/client/room-client/ready) resolves. On the client that [`connect()`](/docs/client/connect) and `ready` resolve to, it's typed as set.

### Exceptions

`TypeError`
: Thrown if a field of `state` is written. The room owns the shared state; to change it, send a message or make a call.

## Description

The client applies each state update whole, so the fields of `state` always come from one tick of the room. Shared state is entity 0, so [`entities.onChange()`](/docs/client/entity-store/onchange) with the schema's `state` kind runs when its fields change.

After a reconnect the room may send the shared state again as a new object. Read `room.state` each time rather than keeping the object.

## Examples

### Showing the round's timer

The room keeps the round's phase and the seconds left in shared state, and the client shows them after each update.

```ts
// timer.ts
import { connect, defineSchema, entity } from "@irtio/client";

const Round = entity("round", { phase: "string", secondsLeft: "u8" });
const room = await connect("main", { schema: defineSchema({ state: Round }) });

room.addEventListener("update", () => {
  const { phase, secondsLeft } = room.state;
  console.log(phase === "countdown" ? `starting in ${secondsLeft}` : phase);
});
```

## See also

- [`RoomClient.private`](/docs/client/room-client/private)
- [`Room.state`](/docs/room/room/state), the room's side
- [State sync](/docs/room/guides/state-sync)
