Room: id property

Available since @irtio/room 0.1Hosted roomsirt dev@irtio/testingSelf-hosted room host

The id read-only property of the Room interface is the room ID.

Value

A string of 1 to 64 characters of A-Z, a-z, 0-9, _ and -, unique within the project. It’s the last segment of the room’s URL, https://rooms.irt.io/<project>/<room ID>.

Description

The ID is set when the room is created: the one given to createRoom, the server API or a connection to a room that didn’t exist, or a generated one. It stays the same across hibernation, wakes and new builds.

Anyone who knows a room’s ID can connect to it while guests are allowed, so a private room shares its join code rather than its ID. Under @irtio/testing, testRoom()’s room is "room".

Examples

A game’s share link is its own page’s URL with the room ID in it, not the room URL.

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

export default defineRoom({
  onMessage(room, connection, message) {
    if (message === "invite") {
      room.send(connection, { type: "invite", link: `https://dots.irt-serve.com/?room=${room.id}` });
    }
  },
});

See also

Runtime availability

Hosted roomsirt dev@irtio/testingSelf-hosted room host
id0.10.10.10.1