RoomClient: id property
Available since
@irtio/client 5.0BrowsersNodeThe id read-only property of the RoomClient interface is the ID of the room the client connects to, the last segment of its url.
Value
A string, decoded from the URL, so a room ID with a space in it has the space rather than %20.
Description
The ID is the room’s within its project: the room’s own room.id is the same string. Passed to connect() with the page’s irt-project meta tag, it names the same room again.
Examples
Remembering the last room
A player who reloads the page goes back to the room they were in.
// last-room.ts
import { connect } from "@irtio/client";
const room = await connect(localStorage.getItem("lastRoom") ?? "main");
localStorage.setItem("lastRoom", room.id);
See also
Runtime availability
| Browsers | Node | |
|---|---|---|
id | 5.0 | 5.0 |