RoomClient: url property
@irtio/client 5.0BrowsersNodeThe url read-only property of the RoomClient interface is the URL of the room the client connects to, absolute.
Value
A string: an http: or https: URL whose path ends in the project and the room ID, such as "https://rooms.irt.io/my-game/main".
Description
The client resolves the URL it was given against the project URL, as new URL(input, project) does, so a relative "main" gives the room main of the page’s project. A ws: or wss: URL names the same room as http: or https:, and url holds it as http: or https:. The query and fragment are dropped.
A room URL is for connecting. Opened in a browser, it shows an error page, not the game, so share the game’s own page instead, with the room in its query.
Examples
Resolving a room ID in a Node script
A Node script has no irt-project meta tag, so it passes the project URL, and url shows the room the ID resolved to.
// resolve.ts
import { connect } from "@irtio/client";
const room = await connect("main", { project: "https://rooms.irt.io/my-game/" });
console.log(room.url); // "https://rooms.irt.io/my-game/main"
See also
Runtime availability
| Browsers | Node | |
|---|---|---|
url | 5.0 | 5.0 |