# RoomClient: ready property

> The ready read-only property of the RoomClient interface is a Promise that resolves to the client once it holds the room's full state.

The **`ready`** read-only property of the [`RoomClient`](/docs/client/room-client) interface is a `Promise` that resolves to the client once it holds the room's full state, when [`connect()`](/docs/client/connect) would resolve.

## Value

A `Promise` that resolves to the same client as a `ReadyRoomClient`, the client typed with [`state`](/docs/client/room-client/state) and [`private`](/docs/client/room-client/private) set.

It rejects with an [`IrtError`](/docs/client/irt-error) when the client fails for good before it's ready, as `connect()` rejects:

- `NetworkError` when the room can't be reached over WebTransport or WebSocket
- an error named for the close code when the router closes the connection with a code the client doesn't retry, such as `VersionError` for 4004
- `TimeoutError` when the `timeout` option passes first, or the `signal` option comes from `AbortSignal.timeout()`
- `NotSupportedError` when the runtime has no global `WebSocket`, as Node before 24
- `AbortError` when another `signal` aborts, with its reason as `cause`, or when [`close()`](/docs/client/room-client/close) is called first

## Description

`ready` settles once. It resolves when the client applies the room's first full state update, and later reconnects don't change it. After it resolves, the client reconnects by itself and fires an [`open` event](/docs/client/room-client/open-event) after each reconnect.

`connect()` is `new RoomClient(input, init)` followed by awaiting `ready`. Construct the client and await `ready` yourself when a listener must be added before the client connects, such as one for the [`waking` event](/docs/client/room-client/waking-event).

## Examples

### Showing that the room is starting

The player sees "Starting the room" while a hibernated room wakes, and an error if the client can't connect.

```ts
// join-screen.ts
import { IrtError, RoomClient } from "@irtio/client";

const client = new RoomClient("main", { timeout: 20_000 });
client.addEventListener("waking", () => console.log("Starting the room"));
try {
  const room = await client.ready;
  console.log(`joined as ${room.player}`);
} catch (e) {
  if (!(e instanceof IrtError)) throw e;
  console.error(`couldn't join: ${e.name}`);
}
```

## See also

- [`connect()`](/docs/client/connect)
- [`RoomClient.readyState`](/docs/client/room-client/readystate)
- [Errors and close codes](/docs/client/errors)
