<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: codeek</title>
    <description>The latest articles on Forem by codeek (@codeek).</description>
    <link>https://forem.com/codeek</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F558313%2F15c20986-66bf-489e-84f6-476d0c00b48e.png</url>
      <title>Forem: codeek</title>
      <link>https://forem.com/codeek</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/codeek"/>
    <language>en</language>
    <item>
      <title>Build Live stream or video call app in React.js in few minutes</title>
      <dc:creator>codeek</dc:creator>
      <pubDate>Fri, 12 Dec 2025 17:04:53 +0000</pubDate>
      <link>https://forem.com/codeek/integrating-realtime-zegocloud-sdk-in-reactjs-19ml</link>
      <guid>https://forem.com/codeek/integrating-realtime-zegocloud-sdk-in-reactjs-19ml</guid>
      <description>&lt;h3&gt;
  
  
  Build a Live stream app in React with Zegocloud 🚀
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuum5c24krs80039iwcm4.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuum5c24krs80039iwcm4.webp" alt="Built live streaming and video call website or application using react and zegocloud" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
If your preference is video, here is a &lt;a href="https://www.youtube.com/watch?v=AR8qMrnvsNs" rel="noopener noreferrer"&gt;video source&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Video calling and live streaming have become must-have features in today's applications, and &lt;strong&gt;ZEGOCLOUD API&lt;/strong&gt; simplifies the integration process remarkably. You can implement &lt;em&gt;complete live streaming functionality, create separate rooms, add in-app chat&lt;/em&gt;, and more with minimal code.&lt;br&gt;
  What makes ZEGOCLOUD particularly attractive is their generous offer: every new account receives &lt;em&gt;10,000 free minutes&lt;/em&gt;, perfect for testing or launching a basic version of your application.&lt;/p&gt;

&lt;p&gt;This guide walks you through creating a live streaming app, step by step — simply follow the instructions and use the code snippets provided here or from ZEGOCLOUD's official documentation.&lt;br&gt;
&lt;a href="//www.zegocloud.com"&gt;Zegocloud&lt;/a&gt;&lt;br&gt;
The flexibility doesn't end with React. ZEGOCLOUD supports multiple modern frameworks including &lt;strong&gt;Nextjs&lt;/strong&gt;, &lt;strong&gt;Angular&lt;/strong&gt;, &lt;strong&gt;Vue&lt;/strong&gt; and also with &lt;strong&gt;Wordpress&lt;/strong&gt; and &lt;strong&gt;HTML&lt;/strong&gt; with framework or code examples available for each. &lt;br&gt;
By following this tutorial, we'll have a fully operational live streaming application in React. Let's dive in! 🚀&lt;/p&gt;
&lt;h2&gt;
  
  
  Project Setup And Prerequisites
&lt;/h2&gt;

&lt;p&gt;Let's make sure we have everything we need before we start:&lt;/p&gt;

&lt;p&gt;1️⃣ Node.js &lt;br&gt;
Make sure &lt;strong&gt;Node.js&lt;/strong&gt; is installed on our machine. If it's not already installed.&lt;/p&gt;

&lt;p&gt;Download and install from the official site:&lt;br&gt;
&lt;a href="https://nodejs.org" rel="noopener noreferrer"&gt;nodejs&lt;/a&gt;&lt;br&gt;
Choose &lt;strong&gt;LTS&lt;/strong&gt; version. &lt;/p&gt;

&lt;p&gt;This installs:&lt;br&gt;
&lt;em&gt;node&lt;br&gt;
npm&lt;br&gt;
npx&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To check if Node.js is installed or needs an update, we need to run the script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node -v  # Check installed version
npm update nodejs  # Update Node.js if needed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Setting up React with Vite
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;First of all, lets create an empty folder with any name, lets say &lt;strong&gt;live-stream-app-react&lt;/strong&gt; and open in your editor like Visual studio Code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Lets now open terminal and run the script&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm create vite@latest .

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We then need to give package name in the prompt, any name you prefer and choose React from the second prompt and then Javascript/Typescript from the third prompt.&lt;br&gt;
This will install all the required packages and dependencies in your folder, &lt;strong&gt;live-stream-app-react&lt;/strong&gt; in our case.&lt;/p&gt;
&lt;h2&gt;
  
  
  Lets sign up for a ZEGOCLOUD Account for free
&lt;/h2&gt;

&lt;p&gt;To use ZEGOCLOUD SDK, we need to sign up for a free account and get our App ID and App Sign here:&lt;br&gt;
&lt;a href="https://console.zegocloud.com/account/signup" rel="noopener noreferrer"&gt;🔗 Sign Up on ZEGOCLOUD&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After signing up, we will receive 10,000 free minutes to test and deploy our live streaming application.&lt;/p&gt;
&lt;h2&gt;
  
  
  Let’s Start: Building a live streaming App with ZEGOCLOUD in React
&lt;/h2&gt;

&lt;p&gt;Now that we have everything set up, let’s start integrating ZEGOCLOUD into our React project step by step.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 1: Install the ZEGOCLOUD SDK
&lt;/h3&gt;

&lt;p&gt;To integrate ZEGOCLOUD into your React project, we will need to install the &lt;strong&gt;SDK&lt;/strong&gt; using the following script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install @zegocloud/zego-uikit-prebuilt

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2: Get our AppID and ServerSecret
&lt;/h2&gt;

&lt;p&gt;Lets now log in to ZEGOCLOUD and navigate to the developer console to obtain our AppID and ServerSecret which we need to use in our project code later to initialize SDK.&lt;/p&gt;

&lt;p&gt;⚠️ Important: Lets keep our AppID and ServerSecret private! We need to consider we never share it with anyone or exposing it to others.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Initialize the SDK in React
&lt;/h2&gt;

&lt;p&gt;Now, modify your App.jsx/App.tsx file to initialize the ZEGOCLOUD SDK and create a function to start live streaming component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import * as React from "react";
import { ZegoUIKitPrebuilt } from "@zegocloud/zego-uikit-prebuilt";

function randomID(len) {
  let result = "";
  if (result) return result;
  var chars = "12345qwertyuiopasdfgh67890jklmnbvcxzMNBVCZXASDQWERTYHGFUIOLKJP",
    maxPos = chars.length,
    i;
  len = len || 5;
  for (i = 0; i &amp;lt; len; i++) {
    result += chars.charAt(Math.floor(Math.random() * maxPos));
  }
  return result;
}

export function getUrlParams(url = window.location.href) {
  let urlStr = url.split("?")[1];
  return new URLSearchParams(urlStr);
}

export default function App() {
  const roomID = getUrlParams().get("roomID") || randomID(5);
  let role_str = getUrlParams(window.location.href).get("role") || "Host";
  const role =
    role_str === "Host"
      ? ZegoUIKitPrebuilt.Host
      : role_str === "Cohost"
      ? ZegoUIKitPrebuilt.Cohost
      : ZegoUIKitPrebuilt.Audience;

  let sharedLinks = [];
  if (role === ZegoUIKitPrebuilt.Host || role === ZegoUIKitPrebuilt.Cohost) {
    sharedLinks.push({
      name: "Join as co-host",
      url:
        window.location.protocol +
        "//" +
        window.location.host +
        window.location.pathname +
        "?roomID=" +
        roomID +
        "&amp;amp;role=Cohost",
    });
  }
  sharedLinks.push({
    name: "Join as audience",
    url:
      window.location.protocol +
      "//" +
      window.location.host +
      window.location.pathname +
      "?roomID=" +
      roomID +
      "&amp;amp;role=Audience",
  });
  // generate Kit Token
  const appID = your_app_id;
  const serverSecret = "your_app_secret";
  const kitToken = ZegoUIKitPrebuilt.generateKitTokenForTest(
    appID,
    serverSecret,
    roomID,
    randomID(5),
    randomID(5)
  );

  // start the call
  let myMeeting = async (element) =&amp;gt; {
    // Create instance object from Kit Token.
    const zp = ZegoUIKitPrebuilt.create(kitToken);
    // start the call
    zp.joinRoom({
      container: element,
      scenario: {
        mode: ZegoUIKitPrebuilt.LiveStreaming,
        config: {
          role,
        },
      },
      sharedLinks,
    });
  };

  return (
    &amp;lt;div
      className="myCallContainer"
      ref={myMeeting}
      style={{ width: "100vw", height: "100vh" }}
    &amp;gt;&amp;lt;/div&amp;gt;
  );
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 4: Add our AppID and ServerSecret
&lt;/h2&gt;

&lt;p&gt;Now, we need to add our &lt;strong&gt;AppID&lt;/strong&gt; and &lt;strong&gt;ServerSecret&lt;/strong&gt; here in this codeblock of above code in App.jsx/App.tsx:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// generate Kit Token
  const appID = your_app_id;
  const serverSecret = "your_app_secret";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 5: Run the App
&lt;/h2&gt;

&lt;p&gt;Now, lets start our project by running the script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run dev

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Our live streaming app is now up and running! 🎉&lt;/p&gt;

&lt;p&gt;🎬 Want a Video Tutorial?&lt;br&gt;
If you prefer watching a video instead of reading, check out my tutorial on YouTube where I explain the entire process step by step! 🎥&lt;br&gt;
&lt;a href="https://www.youtube.com/watch?v=AR8qMrnvsNs" rel="noopener noreferrer"&gt;Youtube video&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And before leaving, we can also connect in github:&lt;br&gt;
&lt;a href="https://github.com/abhishek61067" rel="noopener noreferrer"&gt;My github&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Hurray! 🎉 We have successfully built a fully functional live streaming app using React and ZEGOCLOUD. &lt;/p&gt;

&lt;p&gt;I will be coming back with other tutorials regarding Nextjs, Reactjs and so many other things about Frontend and web development. Until then, have a good time my friends.&lt;/p&gt;

&lt;p&gt;Warm Regards,&lt;br&gt;
Codeek&lt;/p&gt;

</description>
      <category>react</category>
      <category>webdev</category>
      <category>zegocloud</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
