VOOZH about

URL: https://www.geeksforgeeks.org/node-js/how-to-make-a-video-call-app-in-node-js/

⇱ Build a Video call app in Node.js - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Build a Video call app in Node.js

Last Updated : 7 Apr, 2026

In a video calling application, clients share audio/video streams using PeerJS, while Socket.io handles signaling and real-time communication between clients and the server.

Prerequisite

Setting Up the Environment

This step involves creating and initializing a new Node.js project.

mkdir VideoCallApp
cd VideoCallApp
npm init

Install Required Dependencies

Install the necessary packages for the application:

npm install express ejs socket.io uuid
npm install nodemon --save-dev
  • Express: Backend framework for Node.js
  • EJS: Templating engine for dynamic HTML
  • Socket.io: Enables real-time communication
  • Nodemon (optional):Nodemon automatically restarts the server when file changes are detected.
  • UUID:UUID is used to generate unique identifiers (IDs) for users or sessions.

Create Server File

Create a file named server.js

Run the server:

node server.js

Open in browser: http://localhost:4000

πŸ‘ Screenshot-2026-03-31-110923

Create Project Structure

Create the following folders:

πŸ‘ pic1

Index.ejs file:

Client-Side Script:

  • Each user gets a unique ID via PeerJS.
  • The ID is sent to the server using Socket.io
  • The server notifies other connected users.

Server-Side Handling:

Now, when this event occurs the server will tell all the other clients that the new user is connected.

Implementing Core Functionality

We capture the user's audio and video streams using the WebRTC getUserMedia API, which enables access to media devices and provides a media stream for peer-to-peer transmission.

Step 1: Capture User Media

Step 2: Send Stream to Other Clients

To share the stream, we use PeerJS call(), which enables peer-to-peer media exchange.

  • Client 1 (Caller): Initiates a call using peer.call() and sends its media stream.
  • Client 2 (Receiver): Listens for incoming calls using peer.on('call') and responds using call.answer().

Output:

πŸ‘ Screenshot71-660x492
  • Both clients successfully exchange audio and video streams.
  • Real-time video communication is established.
  • Each user can see the other’s video feed.
Comment

Explore