# Connection: id property

> The id read-only property of the Connection interface identifies the connection among the room's open connections.

The **`id`** read-only property of the [`Connection`](/docs/room/connection) interface identifies the connection among the room's open connections.

## Value

A number. No two open connections of the room have the same ID, and it's the connection's key in [`room.connections`](/docs/room/room/connections).

## Description

The ID belongs to the connection, not to the player. A player who reconnects, after a dropped network or from a new tab, gets a new connection with a new ID. When a sleeping room wakes, each connection it held comes back with a new ID too. To keep something for a player across connections, key it by [`player`](/docs/room/connection/player).

## Examples

### Passing the turn around the table

```ts
// turns.ts
import { defineRoom } from "@irtio/room";

export default defineRoom({
  data: () => ({ seats: [] as number[], turn: 0 }),
  onJoin(room, connection) {
    room.data.seats.push(connection.id);
  },
  onLeave(room, connection) {
    room.data.seats = room.data.seats.filter((id) => id !== connection.id);
  },
  onMessage(room, connection, message) {
    const { seats } = room.data;
    if (message !== "pass" || seats[room.data.turn % seats.length] !== connection.id) return;
    room.data.turn++;
    const next = room.connections.get(seats[room.data.turn % seats.length]!);
    if (next) room.send(next, { type: "your-turn" });
  },
});
```

## See also

- [`Connection.player`](/docs/room/connection/player)
- [`Room.send()`](/docs/room/room/send)
