Connection: meta property

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

The meta read-only property of the Connection interface is the meta claim of the token the connection was opened with.

Value

The claim’s value, typed unknown, or null when there’s none.

Description

meta is what your backend put in the player’s token, such as a display name, a team or a cosmetic. Check its shape before using it.

A name string of at most 64 characters in meta becomes the player’s presence name when it joins.

Examples

Putting a player on the team its token names

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

export default defineRoom({
  onJoin(room, connection) {
    const meta = connection.meta as { team?: unknown } | null;
    connection.data.team = meta?.team === "red" ? "red" : "blue";
    room.send(connection, { type: "team", team: connection.data.team });
  },
});

See also

Runtime availability

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