<?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>DEV Community: Rajan Surani</title>
    <description>The latest articles on DEV Community by Rajan Surani (@rajansurani).</description>
    <link>https://dev.to/rajansurani</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%2F821665%2Ffec7f017-920a-45d0-a91f-b23049898b99.jpg</url>
      <title>DEV Community: Rajan Surani</title>
      <link>https://dev.to/rajansurani</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rajansurani"/>
    <language>en</language>
    <item>
      <title>Build a JavaScript Video Chat App with VideoSDK</title>
      <dc:creator>Rajan Surani</dc:creator>
      <pubDate>Mon, 28 Feb 2022 14:01:14 +0000</pubDate>
      <link>https://dev.to/video-sdk/webrtc-video-chat-3ha9</link>
      <guid>https://dev.to/video-sdk/webrtc-video-chat-3ha9</guid>
      <description>&lt;p&gt;We have seen a major increase in the usage of virtual meetings in the past year and the existing platforms cannot cater to everyone's custom needs. Also, building a custom feature-rich solution for your need from scratch is not a great option as you need to manage a lot of tasks, this is where &lt;strong&gt;VideoSDK.live&lt;/strong&gt; comes to rescue.&lt;/p&gt;

&lt;p&gt;With &lt;strong&gt;video SDK&lt;/strong&gt; you can build a customized Video Chat App with all features your need. We will see in this guide, how you can build a video chat app using &lt;strong&gt;Javascript&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Node.js v12+&lt;/li&gt;
&lt;li&gt;NPM v6+ (comes pre-installed with newer Node versions)&lt;/li&gt;
&lt;li&gt;You should have a video SDK account to generate token. Visit video SDK &lt;a href="https://app.videosdk.live/api-keys"&gt;dashboard&lt;/a&gt; to generate token.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Project Structure
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;root
 ├── index.html
 ├── assets
 │    ├── css
 │    │    ├── index.css
 │    ├── js
 │         ├── index.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Implementation
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Step 1: Adding VideoSDK
&lt;/h3&gt;

&lt;p&gt;Update the &lt;code&gt;index.html&lt;/code&gt; file with the &lt;code&gt;&amp;lt;script ... /&amp;gt;&lt;/code&gt; as shown to add the Javascript SDK to your project.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;If you don't want to use &lt;code&gt;&amp;lt;script ... /&amp;gt;&lt;/code&gt; you can use &lt;code&gt;npm&lt;/code&gt; to install video SDK in your project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;npm&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;install&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="nx"&gt;videosdk.live/js-sdk&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;//or&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;you&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;can&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;use&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;yarn&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;yarn&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="nx"&gt;videosdk.live/js-sdk&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Step 2: Creating the UI
&lt;/h3&gt;

&lt;p&gt;For the interface, we will have simple Join and Create Meeting meeting buttons which will join and create a new meeting room respectively.&lt;br&gt;
The meeting room will show the local participant view, remote participant view and show buttons to toggle mic, webcam, and leave the meeting. &lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;You can get the complete custom &lt;a href="https://gist.github.com/rajansurani/eaf2e4b6f6d7d446f3b977aad6761f22"&gt;CSS style from here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We will declare all the DOM variables we will need in the &lt;code&gt;index.js&lt;/code&gt; file.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h3&gt;
  
  
  Step 3: Meeting Implementation
&lt;/h3&gt;

&lt;p&gt;To start the meeting implementation, we will need the token  so if you don't have one, you can generate it from &lt;a href="https://app.videosdk.live/api-keys"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Now update your token in the &lt;code&gt;index.js&lt;/code&gt; file as shown to add the token in the script and add a validator.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;We have got the token. Now we will add the meetingHandler which will create or join to a meeting room.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Now the meetingId is either generated or updated with the value user entered. After this, startMeeting is triggered which is responsible to initialize the meeting with the required configuration and join the meeting.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Now we will create the local participant view.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;To show the remote participants, we will add the event listeners on meeting which will notify us when a participant joins or leaves the meeting.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;At last, we will add the event listeners to the toggle buttons and leave button.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Run and Test
&lt;/h3&gt;

&lt;p&gt;To run the app you will need &lt;code&gt;live-server&lt;/code&gt;. If you don't have it installed already you can do it using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;npm&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;install&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-g&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;live-server&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you have the &lt;code&gt;live-server&lt;/code&gt; installed, just run it using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;live-server&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;With this, we successfully built the video chat app using the video SDK in Javascript. If you wish to add functionalities like chat messaging, screen sharing, you can always check out our &lt;a href="https://docs.videosdk.live/"&gt;documentation&lt;/a&gt;. If you face any difficulty with the implementation you can connect with us on our &lt;a href="https://discord.gg/Gpmj6eCq5u"&gt;discord community&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webrtc</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
