# RoomClient: startCountdown() method

> The startCountdown() method of the RoomClient interface starts a lobby's countdown, as the lobby's leader.

The **`startCountdown()`** method of the [`RoomClient`](/docs/client/room-client) interface starts a lobby's countdown, as the lobby's leader. It's the lobby's call `start`.

## Syntax

```ts
startCountdown()
```

### Parameters

None.

### Return value

A `Promise` that resolves with `undefined` once the countdown has started.

### Exceptions

`IrtError`
: Rejects with this if the call fails. Its `name` says why:

  `OperationError`
  : The lobby refused, and its `reason` says why: this player isn't the leader, the lobby has fewer people and bots than its `minPlayers`, or it's already counting down or handing off. In a room that isn't a lobby, the room has no `start` call to answer.

  `TimeoutError`
  : The lobby didn't answer within 10 seconds.

  `NetworkError`
  : The connection dropped before the answer, or the client is reconnecting.

  `InvalidStateError`
  : The client hasn't been ready yet, or it's closed.

## Description

The leader can start the countdown under any of the lobby's start rules, whoever is ready. Under `"leader"`, it's the only way the countdown starts. The leader is `room.presence.leader`, and the presence list's [`leader` event](/docs/client/presence-list/leader-event) fires when it changes. When the countdown ends, the lobby hands its players off to the room it starts; see [Lobbies and parties](/docs/room/guides/lobbies).

[`room.lobby`](/docs/client/room-client/lobby) changes to the `"countdown"` phase, with `startsAt` set, and the [`lobby` event](/docs/client/room-client/lobby-event) fires.

## Examples

### Showing a start button to the leader

The button shows only to the leader while the lobby waits. When the lobby refuses, the player sees its reason.

```ts
// start-button.ts
import { connect, IrtError } from "@irtio/client";

const room = await connect("lobby", { type: "lobby" });
const button = document.querySelector<HTMLButtonElement>("#start")!;

function show() {
  button.hidden = room.presence.leader !== room.player || room.lobby?.phase !== "waiting";
}
room.addEventListener("lobby", show);
room.presence.addEventListener("leader", show);

button.addEventListener("click", async () => {
  try {
    await room.startCountdown();
  } catch (e) {
    // Such as fewer players than the lobby's minPlayers
    if (e instanceof IrtError && e.name === "OperationError") console.warn(e.reason);
    else throw e;
  }
});
```

## See also

- [`RoomClient.cancelCountdown()`](/docs/client/room-client/cancelcountdown)
- [`RoomClient.setLobbyReady()`](/docs/client/room-client/setlobbyready)
- [`handoff` event](/docs/client/room-client/handoff-event)
- [Lobbies and parties](/docs/room/guides/lobbies)
