# RoomCloseEvent: code property

> The code read-only property of the RoomCloseEvent interface is the close code the connection ended or dropped with.

The **`code`** read-only property of the [`RoomCloseEvent`](/docs/client/room-close-event) interface is the close code the connection ended or dropped with.

## Value

A number.

- 4000 to 4099: the router or the room closed the connection, with one of IRT's codes. `CloseCode` names each, such as `CloseCode.RoomHibernated` for 4011.
- 1000: on a [`close` event](/docs/client/room-client/close-event), the client closed with [`close()`](/docs/client/room-client/close).
- 0: on `close`, the first connection failed before any close: the room couldn't be reached, `timeout` passed or the `signal` aborted.
- Any other number: the transport's own close code, on a [`reconnecting` event](/docs/client/room-client/reconnecting-event).

## Description

On `close`, `code` is also the [`code`](/docs/client/irt-error/code) of the event's [`error`](/docs/client/room-close-event/error). [Errors and close codes](/docs/client/errors#close-codes) lists every code, what causes it and whether the client reconnects after it.

## Examples

### Offering a rejoin after the room hibernates

A room that hibernates on its own request closes its connections with 4011, and the client doesn't reconnect by itself. The game offers the player a button instead.

```ts
// rejoin.ts
import { CloseCode, connect } from "@irtio/client";

const room = await connect("https://rooms.irt.io/my-game/garden");
const rejoin = document.querySelector<HTMLButtonElement>("#rejoin")!;

room.addEventListener("close", (event) => {
  if (event.code !== CloseCode.RoomHibernated) return;
  rejoin.hidden = false;
  rejoin.onclick = () => location.reload();
});
```

## See also

- [`RoomCloseEvent.reason`](/docs/client/room-close-event/reason)
- [`Room.hibernate()`](/docs/room/room/hibernate), which closes with 4011
- [Errors and close codes](/docs/client/errors#close-codes)
