Only  $9.9! Get 50,000 minutes with our Starter Plan, perfect for your MVP project.
Only $9.9! Get 50,000 minutes with our Starter Plan, perfect for your MVP project.
Grab It Now 
Call
Overview
  • Android
    • Run Sample Demo
    • Integration
    • UI Customization
    • Offline Call Push
    • On-Cloud Recording
    • More Features
      • Configuring Nicknames and Avatars
      • Group Call
      • Floating Window
      • Custom Ringtone
      • Monitoring Call Status
    • API Documentation
      • API Overview
      • TUICallKit
      • TUICallEngine
      • TUICallObserver
      • Type Definition
    • Server APIs
      • Call Status Callback
        • Call Status Callback
        • Call Event Callback
        • Callback Configuration
          • API List for Callback Configuration
          • Establishing Callback Configuration
          • Retrieving Callback Configuration
          • Update Callback Configuration
          • Remove Callback Configuration
      • REST API
        • Introduction to REST API
        • Retrieve records via callId
        • Retrieve Records Based on Conditions
    • Release Notes
  • iOS
    • Run Sample Demo
    • Integration
    • UI Customization
    • Offline Call Push
      • VoIP
      • APNs
    • On-Cloud Recording
    • More Features
      • Configuring Nicknames and Avatars
      • Group Call
      • Floating Window
      • Custom Ringtone
      • Monitoring Call Status
    • API Documentation
      • API Overview
      • TUICallKit
      • TUICallEngine
      • TUICallObserver
      • Type Definition
    • Server APIs
      • Call Status Callback
        • Call Status Callback
        • Call Event Callback
        • Callback Configuration
          • API List for Callback Configuration
          • Establishing Callback Configuration
          • Retrieving Callback Configuration
          • Update Callback Configuration
          • Remove Callback Configuration
      • REST API
        • Introduction to REST API
        • Retrieve records via callId
        • Retrieve Records Based on Conditions
    • Release Notes
  • Web
    • Run Sample Demo
    • Integration
      • Web&H5 (React)
      • Web&H5 (Vue3)
    • UI Customization
    • On-Cloud Recording
    • More Features
      • Configuring Nicknames and Avatars
      • Configure Resolution and Fill Mode
      • Group Call
      • Floating Window
      • Custom Ringtone
      • Monitoring Call Status
    • API Documentation
      • API Overview
      • TUICallKit
      • TUICallEngine
      • TUICallEvent
    • Server APIs
      • Call Status Callback
        • Call Status Callback
        • Call Event Callback
        • Callback Configuration
          • API List for Callback Configuration
          • Establishing Callback Configuration
          • Retrieving Callback Configuration
          • Update Callback Configuration
          • Remove Callback Configuration
      • REST API
        • Introduction to REST API
        • Retrieve records via callId
        • Retrieve Records Based on Conditions
    • Release Notes
  • Flutter
    • Run Sample Demo
    • Integration
    • Offline Call Push
    • UI Customization
    • On-Cloud Recording
    • More Features
      • Configuring Nicknames and Avatars
      • Group Call
      • Floating Window
      • Beauty Effects
      • Custom Ringtone
      • Monitoring Call Status
    • API Documentation
      • API Overview
      • TUICallKit
      • TUICallEngine
      • TUICallObserver
      • Type Definition
    • Server APIs
      • Call Status Callback
        • Call Status Callback
        • Call Event Callback
        • Callback Configuration
          • API List for Callback Configuration
          • Establishing Callback Configuration
          • Retrieving Callback Configuration
          • Update Callback Configuration
          • Remove Callback Configuration
      • REST API
        • Introduction to REST API
        • Retrieve records via callId
        • Retrieve Records Based on Conditions
    • Upgrading
    • Release Notes
  • Overview
    • Overview
  • Activate the Service
  • Pricing
    • Call Monthly Packages
    • Pay-As-You-Go
    • Free Minutes
  • ErrorCode
  • FAQs
    • All Platform
    • Flutter
    • Web
Call

Web&H5 (React)

This article will guide you through the quick integration of the TUICallKit component. You will complete several key steps within 10 minutes, ultimately obtaining a video call feature with a complete UI interface.
Desktop Version
Mobile Version
Video Call
Audio Call






One-on-one call
Group call







TUICallKit Demo Experience

If you want to directly try out audio and video calling,please enter the Demo experience page.
If you want to quickly implement a new project, directly read Web Demo Quick Start.

Environment preparations

React ≥ v18.0.
Node.js Version: Node.js ≥ v12.13.0 (the official LTS version is recommended, please ensure that the npm version matches the node version).
Modern browser, supporting WebRTC APIs.

Step 1. Activate the service

Before using the Audio and Video Services provided by Tencent Cloud, you need to go to the Console and activate the service for your application. For detailed steps, refer to Activate Service.

Step Two: Establish a React Project

1. If you have not installed create-react-app yet, you can do so in the terminal or cmd using the following method:
npm install -g create-react-app
2. Create a fresh React project. It is at your discretion whether to employ a 'ts' template or not.
npx create-react-app tuicallkit-demo --template typescript
3. After the project is created, go to the project directory.
cd tuicallkit-demo

Step Three: Download the TUICallKit Component

1. Download the @tencentcloud/call-uikit-react component via npm and use it in your project.
npm install @tencentcloud/call-uikit-react
2. Copy the debug directory to your project directory, tuicallkit-demo/src.
MacOS
Windows
cp -r node_modules/@tencentcloud/call-uikit-react/debug ./src
xcopy node_modules\@tencentcloud\call-uikit-react\debug .\src\debug /i /e

Step Four: Include the TUICallKit Component

1. The following code example includes four parameters: SDKAppID, SDKSecretKey, userID, and callUserID.
SDKAppID: The Audio and Video Application's SDKAppID created in Tencent Cloud, refer to Activate the Service.
SDKSecretKey: User Signature, refer to Activate the Service.
userID: The caller's userID. It's a string type that can only include English letters (a to z and A to Z), numbers (0 to 9), hyphens (-), and underscores (_).
callUserID: The called party's userID which must already exist for initialisation. (Within the demo, input the callUserID if there is a callee, otherwise if there isn't a callee it can be left blank).
2. Incorporate the following code in tuicallkit-demo/src/App.tsx.
import React, { useState, useMemo } from "react";
// @ts-ignore
import { TUICallKit, TUICallKitServer, TUIGlobal } from "@tencentcloud/call-uikit-react";
import * as GenerateTestUserSig from "./debug/GenerateTestUserSig-es";

function App() {
const [userData, setUserData] = useState({
userID: "",
callUserID: "",
SDKAppID: 0, // Replace with your SDKAppID
SDKSecretKey: "", // Replace with your SDKSecretKey
isLogin: false,
});
const init = async () => {
const { SDKAppID, SDKSecretKey, userID } = userData;
if (SDKAppID && SDKSecretKey && userID) {
try {
await login(SDKAppID, SDKSecretKey, userID);
setUserData((prevState) => ({
...prevState,
isLogin: true as boolean,
}));
alert("[TUICallKit] login success.");
} catch (error) {
console.error(error);
}
} else {
alert("[TUICallKit] Please fill in the SDKAppID, userID and SecretKey.");
}
};
const login = async (SDKAppID: any, SecretKey: any, userId: any) => {
const { userSig } = GenerateTestUserSig.genTestUserSig({
userID: userId,
SDKAppID: Number(SDKAppID),
SecretKey: SecretKey,
});
await TUICallKitServer.init({ //[1]Initialize the TUICallKit component
userID: userId,
userSig,
SDKAppID: Number(SDKAppID),
});
};
const call = async () => {
await TUICallKitServer.call({ userID: userData.callUserID, type: 2 }); //[2]Make a 1v1 video call
};
const callKitStyle = useMemo(() => {
if (TUIGlobal.isPC) {
return { width: '960px', height: '630px', margin: '0 auto' };
}
return { width: '100%', height: window.innerHeight };
}, [TUIGlobal.isPC]);

return (
<>
<TUICallKit style={callKitStyle}></TUICallKit>
<div style={{ width: 350, margin: '0 auto' }}>
<h4> {userData.isLogin ? "Call Panel" : "Login Panel"} </h4>
<input
value={userData.isLogin ? userData.callUserID : userData.userID}
onChange={(value) => {
const key = userData.isLogin ? "callUserID" : "userID";
setUserData((prevState) => ({
...prevState,
[key]: value.target.value,
}));
}}
style={{ width: 230, margin: '0 auto' }}
placeholder={
userData.isLogin ? "Please enter callee's userID" : "Please enter your userID"
}
/>
<button onClick={userData.isLogin ? call : init}> {userData.isLogin ? "call" : "login"} </button>
<p style={{margin: '10'}}> {userData.isLogin ? `Your userID: ${userData.userID}` : ""} </p>
</div>
</>
);
}
export default App;

Step Five: Make your first phone call

1. Execute npm run start in the terminal to run tuicallkit-demo.
Alert: Visit locally through localhost protocol, for details refer to Network access protocol description.
2. Enter the userID for login, click the login button, 'login success' pop-up indicates successful initialization.



3. Enter the recipient's userID, click the call button, initiate a 1v1 video call.




Additional Features

FAQs

If you encounter any issues during integration and use, please refer to Frequently Asked Questions.

Technical Consultation

If you have any requirements or feedback, you can contact: info_rtc@tencent.com.