# @tencentcloud/tuiroom-engine-js

> TUIRoomEngine Web SDK

Latest version **4.2.5** (published 2026-08-28) · ISC license · 0 weekly downloads

## Install

```sh
npm install @tencentcloud/tuiroom-engine-js
pnpm add @tencentcloud/tuiroom-engine-js
yarn add @tencentcloud/tuiroom-engine-js
bun add @tencentcloud/tuiroom-engine-js
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 4.2.5 |
| Published | 2026-08-28 |
| First published | 2022-12-13 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 6.4 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 160 |
| Author | Tencent Cloud Client R&D Center |
| Maintainers | alsotang, wbxl2000, xinli123, viktorli, ashfieldfox, ashster, dawnrking, bernlao, llwyct, allen0809npm, oriettazimmerfeng, kyonqi, rychouwei, rgzhao |
| Keywords | tuiroom, webrtc, im, javascript |

## Links

- npm: https://www.npmjs.com/package/@tencentcloud/tuiroom-engine-js
- Repository: https://github.com/tencentyun/TUIRoom
- Homepage: https://cloud.tencent.com/document/product/647/81970
- Issues: https://github.com/tencentyun/TUIRoom/issues
- npm.io page: https://npm.io/package/@tencentcloud/tuiroom-engine-js

## Dependencies (4)

- [rtc-detect](https://npm.io/package/rtc-detect.md) ^0.0.5
- [tcplayer.js](https://npm.io/package/tcplayer.js.md) 5.3.4-beta.34
- [trtc-cloud-js-sdk](https://npm.io/package/trtc-cloud-js-sdk.md) 2.14.2
- [@tencentcloud/lite-chat](https://npm.io/package/@tencentcloud/lite-chat.md) ^1.6.18

## Alternatives

- [@js-joda/timezone](https://npm.io/package/@js-joda/timezone.md) — 383.4K weekly downloads
- [chartjs-adapter-moment](https://npm.io/package/chartjs-adapter-moment.md) — 210.8K weekly downloads
- [strftime](https://npm.io/package/strftime.md) — 171.2K weekly downloads
- [vue-flatpickr-component](https://npm.io/package/vue-flatpickr-component.md) — 115.8K weekly downloads
- [timepicker](https://npm.io/package/timepicker.md) — 51.0K weekly downloads

## Recent versions

- 4.2.5 (latest) — 2026-08-28
- 4.2.6-beta.3 (beta) — 2026-09-16
- 3.0.0-alpha.0 (alpha) — 2025-03-21
- 4.2.6-beta.2 — 2026-09-11
- 4.2.6-beta.1 — 2026-09-04
- 4.2.5-beta.1 — 2026-08-24
- 4.2.4 — 2026-08-10
- 4.2.3 — 2026-07-31
- 4.1.2-beta.5 — 2026-07-29
- 4.2.2 — 2026-07-23
- 4.2.1 — 2026-07-13
- 4.2.0 — 2026-07-02
- 4.1.2-beta.4 — 2026-06-24
- 4.1.2-beta.3 — 2026-06-15
- 4.1.2-beta.2 — 2026-06-04
- … 172 more at https://npm.io/package/@tencentcloud/tuiroom-engine-js/versions

## README

### TUIRoomEngine Web SDK

### 简介

TUIRoomEngine Web SDK 依托腾讯云 [实时音视频 TRTC](https://cloud.tencent.com/document/product/647/16788) 和 [即时通信 IM](https://cloud.tencent.com/document/product/269/42440) 服务，为用户提供房间管理，多人实时音视频互动，屏幕分享，成员管理，即时聊天等功能。

+ [官方文档](https://cloud.tencent.com/document/product/647/81962)
+ [体验 Demo](https://web.sdk.qcloud.com/component/tuiroom/index.html)
+ [github](https://github.com/tencentyun/TUIRoomKit/tree/main/Web)

### 安装

```bash
// with npm
npm i @tencentcloud/tuiroom-engine-js --save

// with yarn
yarn add @tencentcloud/tuiroom-engine-js

// with pnpm
pnpm i @tencentcloud/tuiroom-engine-js --save
```

### 示例代码

```javascript
import TUIRoomEngine from '@tencentcloud/tuiroom-engine-js';

let roomEngine = null;

// 错误
function onError(error) {
  console.error(error);
}

// 音量变化
function onUserVoiceVolumeChanged(eventInfo) {
  console.log(eventInfo.userVolumeList);
}

// 网络质量变化
function onUserNetworkQualityChanged(eventInfo) {
  console.log(eventInfo.userNetworkList);
}

// 被踢出房间
function onKickedOutOfRoom(eventInfo) {
  console.log(`roomId: ${eventInfo.roomId}, ${eventInfo.message}`);
}

// 用户签名 userSig 过期
function onUserSigExpired() {
  console.log('userSig expire');
}

// 被踢下线
function onKickedOffLine(eventInfo) {
  console.log(`user offline, reason: ${eventInfo.message}`);
}

// 设备变化：设备切换、设备插拔事件
function onDeviceChange(eventInfo) {
  console.log(`deviceChange ${JSON.stringify(eventInfo)}`);
}

async function init() {
  TUIRoomEngine.once('ready', () => {
    roomEngine = TUIRoomEngine.getInstance();
    roomEngine.on(TUIRoomEvents.onError, onError);
    roomEngine.on(TUIRoomEvents.onUserVoiceVolumeChanged, onUserVoiceVolumeChanged);
    roomEngine.on(TUIRoomEvents.onUserNetworkQualityChanged, onUserNetworkQualityChanged);
    roomEngine.on(TUIRoomEvents.onKickedOutOfRoom, onKickedOutOfRoom);
    roomEngine.on(TUIRoomEvents.onUserSigExpired, onUserSigExpired);
    roomEngine.on(TUIRoomEvents.onKickedOffLine, onKickedOffLine);
    roomEngine.on(TUIRoomEvents.onDeviceChange, onDeviceChange);
  });

  // sdkAppId 获取和 userSig 生成详见官网文档
  // https://cloud.tencent.com/document/product/647/81962#step1
  await TUIRoomEngine.login({ sdkAppId: 0, userId: '', userSig: '' });
  await TUIRoomEngine.setSelfInfo({ userName: 'zhangsan', avatarUrl: 'https://testurl' });
}

init();

```

### API 列表

| API                               | 含义               |
| :-------------------------------- | :----------------- |
| [TUIRoomEngine.login](https://cloud.tencent.com/document/product/647/81970#login)         | 登录 TUIRoomEngine         |
| [TUIRoomEngine.setSelfInfo](https://cloud.tencent.com/document/product/647/81970#setSelfInfo)                | 设置当前用户基本信息（用户名、用户头像）       |
| [TUIRoomEngine.getSelfInfo](https://cloud.tencent.com/document/product/647/81970#getSelfInfo)                | 获取当前用户信息      |
| [TUIRoomEngine.logout](https://cloud.tencent.com/document/product/647/81970#logout)                | 登出 TUIRoomEngine       |
| [roomEngine.createRoom](https://cloud.tencent.com/document/product/647/81970#createRoom)                | 创建房间       |
| [roomEngine.enterRoom](https://cloud.tencent.com/document/product/647/81970#enterRoom)                | 进入房间       |
| [roomEngine.destroyRoom](https://cloud.tencent.com/document/product/647/81970#destroyRoom)                | 销毁房间       |
| [roomEngine.exitRoom](https://cloud.tencent.com/document/product/647/81970#exitRoom)                | 离开房间       |
| [roomEngine.fetchRoomInfo](https://cloud.tencent.com/document/product/647/81970#fetchRoomInfo)                | 获取房间信息       |
| [roomEngine.updateRoomNameByAdmin](https://cloud.tencent.com/document/product/647/81970#updateRoomNameByAdmin)                | 更新房间的名字（仅群主或者管理员可以调用）      |
| [roomEngine.updateRoomSeatModeByAdmin](https://cloud.tencent.com/document/product/647/81970#updateRoomSeatModeByAdmin)                | 更新房间上麦模式（仅群主或者管理员可以调用）       |
| [roomEngine.getUserList](https://cloud.tencent.com/document/product/647/81970#getUserList)                | 获取当前房间用户列表       |
| [roomEngine.getUserInfo](https://cloud.tencent.com/document/product/647/81970#getUserInfo)                | 获取用户的详细信息       |
| [roomEngine.takeSeat](https://cloud.tencent.com/document/product/647/81970#takeSeat)                | 获取麦位       |
| [roomEngine.leaveSeat](https://cloud.tencent.com/document/product/647/81970#leaveSeat)                | 释放麦位       |
| [roomEngine.lockSeatByAdmin](https://cloud.tencent.com/document/product/647/81970#lockSeatByAdmin)                | 锁定某个麦位状态     |
| [roomEngine.getSeatList](https://cloud.tencent.com/document/product/647/81970#getSeatList)                | 获取麦位信息       |
| [roomEngine.openRemoteDeviceByAdmin](https://cloud.tencent.com/document/product/647/81970#openRemoteDeviceByAdmin)                | 请求远端用户打开摄像头       |
| [roomEngine.applyToAdminToOpenLocalDevice](https://cloud.tencent.com/document/product/647/81970#applyToAdminToOpenLocalDevice)                | 参会者向主持人申请打开设备      |
| [roomEngine.closeRemoteDeviceByAdmin](https://cloud.tencent.com/document/product/647/81970#closeRemoteDeviceByAdmin)                | 关闭远端用户设备       |
| [roomEngine.takeUserOnSeatByAdmin](https://cloud.tencent.com/document/product/647/81970#takeUserOnSeatByAdmin)                | 邀请其他人上麦       |
| [roomEngine.kickUserOffSeatByAdmin](https://cloud.tencent.com/document/product/647/81970#kickUserOffSeatByAdmin)                | 要求其他人下麦       |
| [roomEngine.cancelRequest](https://cloud.tencent.com/document/product/647/81970#cancelRequest)                | 取消已经发出的请求       |
| [roomEngine.responseRemoteRequest](https://cloud.tencent.com/document/product/647/81970#responseRemoteRequest)                | 回复远端用户的请求       |
| [roomEngine.setLocalVideoView](https://cloud.tencent.com/document/product/647/81970#setLocalVideoView)                | 设置本地流的渲染位置       |
| [roomEngine.openLocalCamera](https://cloud.tencent.com/document/product/647/81970#openLocalCamera)                | 本地摄像头视频流采集       |
| [roomEngine.closeLocalCamera](https://cloud.tencent.com/document/product/647/81970#closeLocalCamera)                | 关闭本地摄像头       |
| [roomEngine.openLocalMicrophone](https://cloud.tencent.com/document/product/647/81970#openLocalMicrophone)                | 打开本地麦克风       |
| [roomEngine.closeLocalMicrophone](https://cloud.tencent.com/document/product/647/81970#closeLocalMicrophone)                | 关闭本地麦克风       |
| [roomEngine.updateVideoQuality](https://cloud.tencent.com/document/product/647/81970#updateVideoQuality)                | 设置本地视频流的编码参数      |
| [roomEngine.updateAudioQuality](https://cloud.tencent.com/document/product/647/81970#updateAudioQuality)                | 设置本地音频的参数       |
| [roomEngine.startPushLocalVideo](https://cloud.tencent.com/document/product/647/81970#startPushLocalVideo)                | 开始向远端推本地视频流     |
| [roomEngine.stopPushLocalVideo](https://cloud.tencent.com/document/product/647/81970#stopPushLocalVideo)                | 停止向远端推本地视频流       |
| [roomEngine.setRemoteVideoView](https://cloud.tencent.com/document/product/647/81970#setRemoteVideoView)                | 设置远端流渲染的区域       |
| [roomEngine.startPlayRemoteVideo](https://cloud.tencent.com/document/product/647/81970#startPlayRemoteVideo)                | 开始播放远端用户视频流       |
| [roomEngine.stopPlayRemoteVideo](https://cloud.tencent.com/document/product/647/81970#stopPlayRemoteVideo)                | 停止播放远端用户视频流       |
| [roomEngine.muteRemoteAudioStream](https://cloud.tencent.com/document/product/647/81970#muteRemoteAudioStream)                | 停止播放远端用户的音频流       |
| [roomEngine.changeUserRole](https://cloud.tencent.com/document/product/647/81970#changeUserRole)                | 改变用户的角色       |
| [roomEngine.kickRemoteUserOutOfRoom](https://cloud.tencent.com/document/product/647/81970#kickRemoteUserOutOfRoom)                | 将用户踢出房间      |
| [roomEngine.disableDeviceForAllUserByAdmin](https://cloud.tencent.com/document/product/647/81970#disableDeviceForAllUserByAdmin)                | 所有用户的设备是否允许被使用      |
| [roomEngine.disableSendingMessageForAllUser](https://cloud.tencent.com/document/product/647/81970#disableSendingMessageForAllUser)                | 所有用户的是否允许发消息      |
| [roomEngine.disableSendingMessageByAdmin](https://cloud.tencent.com/document/product/647/81970#disableSendingMessageByAdmin)                | 特定用户是否被允许发消息      |
| [~~roomEngine.sendTextMessage~~](https://cloud.tencent.com/document/product/647/81970#sendTextMessage)                | 发送文本消息，该接口自 v2.0.0 版本废弃       |
| [~~roomEngine.sendCustomMessage~~](https://cloud.tencent.com/document/product/647/81970#sendCustomMessage)                | 发送自定义消息，该接口自 v2.0.0 版本废弃       |
| [roomEngine.startScreenSharing](https://cloud.tencent.com/document/product/647/81970#startScreenSharing)                | 开始屏幕共享       |
| [roomEngine.stopScreenSharing](https://cloud.tencent.com/document/product/647/81970#stopScreenSharing)                | 停止屏幕共享       |
| [roomEngine.on](https://cloud.tencent.com/document/product/647/81970#on)                | 监听 roomEngine 的事件       |
| [roomEngine.off](https://cloud.tencent.com/document/product/647/81970#off)                | 取消监听 roomEngine 的事件       |
| [roomEngine.getCameraDevicesList](https://cloud.tencent.com/document/product/647/81970#getCameraDevicesList)                | 获取摄像头设备列表       |
| [roomEngine.getMicDevicesList](https://cloud.tencent.com/document/product/647/81970#getMicDevicesList)                | 获取麦克风设备列表       |
| [roomEngine.getSpeakerDevicesList](https://cloud.tencent.com/document/product/647/81970#getSpeakerDevicesList)                | 获取扬声器设备列表       |
| [roomEngine.setCurrentCameraDevice](https://cloud.tencent.com/document/product/647/81970#setCurrentCameraDevice)                | 设置要使用的摄像头设备       |
| [roomEngine.setCurrentMicDevice](https://cloud.tencent.com/document/product/647/81970#setCurrentMicDevice)                | 设置要使用的麦克风设备       |
| [roomEngine.setCurrentSpeakerDevice](https://cloud.tencent.com/document/product/647/81970#setCurrentSpeakerDevice)                | 设置要使用的扬声器设备       |
| [roomEngine.getCurrentCameraDevice](https://cloud.tencent.com/document/product/647/81970#getCurrentCameraDevice)                | 获取当前正在使用的摄像头设备       |
| [roomEngine.getCurrentMicDevice](https://cloud.tencent.com/document/product/647/81970#getCurrentMicDevice)                | 获取当前正在使用的麦克风设备       |
| [roomEngine.getCurrentSpeakerDevice](https://cloud.tencent.com/document/product/647/81970#getCurrentSpeakerDevice)                | 获取当前正在使用的扬声器设备       |
| [roomEngine.startCameraDeviceTest](https://cloud.tencent.com/document/product/647/81970#startCameraDeviceTest)                | 开始进行摄像头测试       |
| [roomEngine.stopCameraDeviceTest](https://cloud.tencent.com/document/product/647/81970#stopCameraDeviceTest)                | 停止摄像头测试       |
| [roomEngine.getTRTCCloud](https://cloud.tencent.com/document/product/647/81970#getTRTCCloud)                | 获取 trtcCloud 实例       |
| [roomEngine.getTIM](https://cloud.tencent.com/document/product/647/81970#getTIM)                | 获取 tim 实例       |

### 参考文档
- [TUIRoomEngine](https://cloud.tencent.com/document/product/647/81970)
- [腾讯实时音视频 TRTC](https://cloud.tencent.com/document/product/647/16788)
- [腾讯云即时通信 IM](https://cloud.tencent.com/document/product/269/1498)

---
_Source: https://npm.io/package/@tencentcloud/tuiroom-engine-js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
