how to update roomname
# ask-ai
b
how to update roomname
t
Thanks for reaching out, Mohammed. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m responding to your question about updating a room name. You cannot rename a room once it’s created. The room’s
roomName
is a fixed identifier. Two ways to handle this: • Create a new room with the desired name, then move participants to it (LiveKit Cloud only). a. Create the new room (
CreateRoom
). b. Move participants with
MoveParticipant(oldRoom, participantIdentity, newRoom)
. c. Delete the old room if you no longer need it (
DeleteRoom
). • If you only need a different display name for users, update the room’s metadata instead: ◦ Use
updateRoomMetadata(roomName, JSON.stringify({ displayName: 'My Updated Room Title', ... }))
◦ Clients can read the metadata from the
Room
object and show the display name in the UI. Which approach fits your use case — actually renaming for backend references (create + move) or just changing what users see (metadata)? If you want, tell me whether you’re on LiveKit Cloud and I can provide exact API examples for your setup. Sources: server-sdk-js | livekit/livekit_composite | DeepWiki | Managing participants | LiveKit docs | Managing rooms | LiveKit docs | Room metadata | LiveKit docs
b
iam using python, how to update metadata
t
Thanks — I’m responding to your question about updating room metadata in Python. If you’re using the LiveKit Python API client, call
update_room_metadata
on the room service. Metadata must be a string (JSON is recommended) and is limited to 64 KiB. Example:
Copy code
from livekit.api import LiveKitAPI, UpdateRoomMetadataRequest
import asyncio
import os

async def update_metadata():
    # Ensure LIVEKIT_URL, LIVEKIT_API_KEY, LIVEKIT_API_SECRET are set in env
    lkapi = LiveKitAPI()

    resp = await lkapi.room.update_room_metadata(
        UpdateRoomMetadataRequest(
            room="my-room-name",
            metadata='{"displayName":"My Updated Room Title","topic":"New topic"}'
        )
    )
    print("Updated:", resp)

if __name__ == "__main__":
    asyncio.run(update_metadata())
Notes: • Metadata must be a string (use JSON for structure). • Ensure your API key has room-admin permissions for this operation. • Metadata size limit: 64 KiB. Do you want an example that builds the env-keyed client explicitly (URL/key/secret) or code to move participants between rooms as well? Sources: Participant attributes and metadata | LiveKit docs | Room metadata | LiveKit docs | Managing participants | LiveKit docs
b
how to get this metadata from fontend iam using react
t
You're asking how to read room metadata from a React frontend — good question. Below is a minimal, practical example showing how to access the current metadata and react to updates using the LiveKit client and the
useRoom
hook.
Copy code
import React, { useEffect, useState } from "react";
import { useRoom } from "@livekit/components-react";
import { RoomEvent } from "livekit-client";

export default function RoomMetadataDisplay() {
  const room = useRoom();
  const [metadata, setMetadata] = useState<string | undefined>(room?.metadata);

  useEffect(() => {
    if (!room) return;

    // initial value
    setMetadata(room.metadata);

    // listen for updates
    const onMetadataChanged = (newMetadata?: string) => {
      setMetadata(newMetadata);
    };
    room.on(RoomEvent.RoomMetadataChanged, onMetadataChanged);

    // cleanup
    return () => {
      room.off(RoomEvent.RoomMetadataChanged, onMetadataChanged);
    };
  }, [room]);

  return <div>{metadata ? JSON.parse(metadata).displayName ?? metadata : "No metadata"}</div>;
}
Notes: •
room.metadata
is a string (JSON is commonly used). Parse it if you stored structured data. • Listen to
RoomEvent.RoomMetadataChanged
to get live updates. • Only the server can update metadata; clients can read it. Sources: Room metadata | LiveKit docs | Handling events | LiveKit docs