# RoomClient: waking event

> The waking event of the RoomClient interface fires when the room isn't running and the connection is held while it starts.

The **`waking`** event of the [`RoomClient`](/docs/client/room-client) interface fires when the room isn't running and the router holds the connection while it starts.

## Syntax

```ts
addEventListener("waking", (event) => {})
```

## Event type

A plain `Event`, with no properties of its own.

## Description

The router sends `waking` before it has looked up whether the room has room state, so it fires for every start, not only a wake: a hibernated room waking, the first start of a room this connection creates and a restart after a crash. Show something neutral, such as "Starting the room".

When it fires, [`readyState`](/docs/client/room-client/readystate) is `"waking"`. On the first connection it fires before [`connect()`](/docs/client/connect) resolves, so a listener added after `await connect(...)` never sees it. To show a room starting, construct the client with `new RoomClient(input, init)`, which connects as `connect()` does without waiting, add the listener, then await its [`ready`](/docs/client/room-client/ready).

The time a start took is in [`joinTime`](/docs/client/room-client/jointime) once the client is ready, whose `started` is `true` when the router sent `waking` on the way.

## Examples

### Showing a loader while the room starts

The loader says the room is starting only when the router reports it, and clears once the client holds the room's state.

```ts
// loader.ts
import { RoomClient } from "@irtio/client";

const loader = document.querySelector("#loader")!;
const client = new RoomClient("https://rooms.irt.io/my-game/castle");
client.addEventListener("waking", () => {
  loader.textContent = "Starting the room";
});

try {
  const room = await client.ready;
  loader.textContent = "";
  console.log(`joined as ${room.player}`);
} catch (e) {
  loader.textContent = "Couldn't reach the room";
  console.error(e);
}
```

## See also

- [`open` event](/docs/client/room-client/open-event)
- [`RoomClient.joinTime`](/docs/client/room-client/jointime)
- [How a room wakes](/docs/room/guides/hibernation#how-a-room-wakes), for what the room does meanwhile
- [Join loader](/docs/client/ui-kit#irt-join-loader), for a ready-made loader
