How to migrate your existing rooms IDs to use access token naming patterns
When using access token authentication we
recommend using a naming pattern for your room IDs. If you’ve already created
rooms, it’s possible to rename them with @liveblocks/node
or our REST API.
Update your room IDs
To rename a room ID, you can use the liveblocks.updateRoomId endpoint to update a room ID.
When you change a room ID, currently connected users will disconnect, but there is a way around this.
Handle active users connected to a room
To avoid users disconnecting after the change, you can listen for a room ID
changed error, 4006
, with
useErrorListener
or
room.subscribe("error")
.
This error is sent immediately after the ID is changed, and it returns the new
room ID inside error.message
. You can use this the new ID to redirect users to
the new location of the room in your application.
After implementing this, you can safely update the room ID, and users will be immediately redirected to the new location.