TUIRoomKit is a UI solution for audio/video conferencing rooms provided by TRTC. This guide explains how to integrate TUIRoomKit into an existing Vue3 project and how to customize its styles, layouts, and features.
Desktop Multi-Party Conference
H5 Multi-Party Conference
Prerequisites
Activate the Service
See Activate the Service to obtain the TUIRoomKit trial version and retrieve your SDKAppID and SDKSecretKey.
SDKAppID: Application identifier. TRTC uses SDKAppID for billing statistics.
SDKSecretKey: Application secret, used to initialize configuration files with sensitive information.
Environment Setup
Node.js: ≥ 18.19.1 (official LTS version recommended)
Vue: ≥ 3.4.21
Modern browsers: Browsers that support WebRTC APIs
Devices: Camera, microphone, speaker
Quick Integration
Step 1: Install Dependencies
Install the following dependencies in your project.
Authentication is required to access all TUIRoomKit features. Call conference.login as soon as your user is authenticated—for example, right after a user logs into your web page. After calling conference.login, we recommend calling conference.setSelfInfo to set the user’s display name and avatar, which are shown in the participant video area and the member list.
Note:
Make sure to use the generated UserSig in your configuration. In production, generate UserSig on your server and have the client request a dynamic UserSig from your business server for authentication as needed. See How to calculate UserSig for production.
Integration Issue: Listening for Authentication Success Across Routes
If your authentication and Enter Room pages use different routes, the Enter Room page may load before conference.login finishes. Use Vue's watch to monitor loginUserInfo.value?.userId. When this value is non-empty, authentication is successful.
The Room ID is the core identifier for a meeting and must be generated and managed by your business system (it must be globally unique). Choose the creation method that fits your business scenario:
Scenario 1: Quick Meeting Created by the Client App
Use Case: The user clicks "Quick Meeting" and the client app immediately creates a room and enters it (for example, ad-hoc communication or IM chat–initiated meetings).
Implementation: The client app either generates the Room ID locally or requests a unique Room ID from the backend, then calls conference.createAndJoinRoom to create the room and enter it.
Use Case: Meetings scheduled for a future time (for example, weekly team meetings or online training). Users can set the meeting title, scheduled time, and invitees in advance.
Implementation: The client app generates (or requests) a unique Room ID from your backend, then calls the scheduleRoom API with the scheduled time and other parameters to create the reservation. After the reservation is created successfully, the meeting details are synced to the invitees’ meeting lists.
Use Case: Meetings scheduled via "Client Scheduling" or "Server-Side Creation". Users can go to the "Meeting List" page to view their scheduled or invited meetings and join quickly.
Implementation: Use the getScheduledRoomList API from useRoomState to fetch the user's scheduled meetings and render them. When the user clicks a meeting, retrieve its Room ID and call conference.joinRoom to Enter Room.
<template>
<div>
<h3>My Scheduled Meetings</h3>
<ul v-if="roomList.length > 0">
<li v-for="room in roomList":key="room.roomId"class="item">
Scenario 3: Enter Room When Existence Is Uncertain
Use Case: Peer-to-peer scenarios (e.g., online consultation, 1v1 video customer service) where you cannot determine if the room has been created.
Implementation: Both parties use a shared business document number (e.g., order number) as Room ID and call conference.createAndJoinRoom to Enter Room.
// No need to check if room exists; SDK handles creation and Enter Room logic automatically
await conference.createAndJoinRoom({
roomId: bizOrderId,
options:{
roomName:`Business Communication: ${bizOrderId}`,
},
});
};
Note:
The conference.createAndJoinRoom API handles: "If the room does not exist, create it (become host); if it exists, join it (become participant)", resolving state conflicts under high concurrency.
Step 6: Leave Room or End Room
TUIRoomKit provides built-in UI buttons for leaving or ending the room. Users can click "Leave Room" or "End Room" directly.
To trigger leave or end actions programmatically, use the following APIs.
Scenario 1: Leave Room
Both participants and hosts can call leaveRoom() to leave the meeting. This does not affect other members; the room remains active.
When the host leaves the room or closes the web page, the room is not automatically ended. Other participants can continue using TUIRoomKit features. The system will automatically reclaim room resources 6 hours after the scheduled end time, provided the room is empty.
Scenario 2: End a Room
When the host calls endRoom(), all participants receive a notification that the room has ended.
endRoom() must be called by the host after successfully Entered Room. Calling as a non-host or before Enter Room will result in an error.
Step 7: Listen to the Room State
In real-world audio/video conferencing, room state can change due to factors like the host ending the meeting, account login on another device, or network issues causing Enter Room failure.
TUIRoomKit automatically handles audio/video resource cleanup and UI prompts, but routing transitions must be managed by your business layer. Register state listeners when the meeting component mounts (onMounted), and remove listeners when the component unmounts (onUnmounted).
Same account logged in on another device, current device forced offline
Redirect to login page
RoomEvent.USER_SIG_EXPIRED
UserSig expired
Redirect to login page
Start the Project
npm
pnpm
yarn
npm run dev
pnpm run dev
yarn run dev
After the project starts successfully, open the debug address in your browser (usually http://localhost:5173) to access the application. You will see a meeting interface like the following:
Next Steps
After completing the basic integration, you can further customize the UI to fit your business requirements.
Configure Theme and Language
Change the default theme and language by setting the UIKitProvider parameters in App.vue.
TUIRoomKit's built-in invite and scheduling selection components use the TRTC IM user relationship chain (friend list) by default. To display your company's internal organization or a custom friend list, first use the Server APIs to sync your business contacts to the TRTC IM system:
TUIRoomKit supports three video stream layouts: grid, sidebar, and top bar. The default is grid layout. To change the layout, call conference.setFeatureConfig.
Does the meeting end immediately if the host closes the web page or exits unexpectedly?
No. If the host closes the browser or disconnects due to network issues, the meeting does not end immediately. The meeting continues, and other participants can interact as usual.
To conserve resources, proactively end the room when the meeting finishes by:
UI operation: Host clicks the "End Room" button in TUIRoomKit UI
Client APIs: Call conference.endRoom()
Server APIs: Use REST API for remote destruction
Note: If not ended proactively, the system will automatically reclaim resources 6 hours after the scheduled end time, provided the room is empty.
Can multiple devices use the same userId to join the same meeting at the same time?
No. TUIRoomKit does not allow the same userId to join the same room from multiple devices simultaneously.
Kick-out mechanism: If a later device attempts to Enter Room with the same userId, the device already in the room will be forcibly logged out.
Solution: To support multi-device (e.g., phone and PC) joining the same meeting, assign a unique userId to each device.
Why does it work locally but fail to access the camera or microphone after deployment?
Cause: Browsers enforce strict security and privacy controls for audio/video device access (microphone, camera). Only secure environments are allowed: https://, localhost, file://, etc. HTTP is considered insecure and browsers will block media device access.
Solution: If local (localhost) tests work but deployment fails, check if your web page is served over HTTP. You must use HTTPS and ensure a valid security certificate.
Yes. To integrate TUIRoomKit via iframe, configure the allow attribute to grant necessary browser permissions (microphone, camera, screen sharing, fullscreen, etc), as shown:
TUIRoomKit offers rich customization out of the box—custom themes and languages, UI tweaks, custom video layouts and widgets, watermarking, and more—so you can meet most UI and interaction requirements without changing the source.
For maintainability, we recommend using the built-in customization options whenever possible, rather than exporting the source. Once exported, you’re no longer on TUIRoomKit’s standard npm upgrade path, which usually means higher long-term maintenance and fewer benefits from future releases (new features, bug fixes, and performance improvements).
Recommended: Start with the options in the UI customization documentation. If the current APIs don’t cover your use case, contact us.
If you’ve assessed the trade-offs and still need deep customization that changes the underlying architecture, you can export the source code as follows:
Vue3
1. Run the source export script. The default copy path is ./src/components/RoomKit
2. Follow the script prompt to confirm whether to copy TUIRoomKit source code to ./src/components/RoomKit. Enter y to customize the copy directory, otherwise enter n.
3. After exporting, TUIRoomKit source code will be added to your specified project path. Update the import path for ConferenceMainView, ConferenceMainViewH5, and the conference object from the npm package to the relative path of the TUIRoom source.