Skip to content

alanoteles/nest-websocket-chat

Repository files navigation

NestJS WebSocket Chat

A simple real-time chat application built with NestJS and Socket.io to demonstrate WebSocket implementation. This project showcases bidirectional communication between server and clients, allowing multiple users to exchange messages instantly through WebSocket connections.

Features

  • Real-time messaging using WebSocket (Socket.io)
  • Multiple users support with broadcast messages
  • User connection/disconnection notifications
  • Clean and responsive UI
  • Simple vanilla JavaScript frontend

Screenshots

Multiple Users Chatting

Multiple Users

How to run the project

1. Backend (NestJS)

# Install dependencies
npm install

# Start the server
npm run start:dev

The WebSocket server will be running at http://localhost:3002

2. Frontend (HTML)

The frontend is a simple HTML file. To test it, you have several options:

Option 1 - Opening directly in the browser: Simply open the index.html file directly in your browser.

Option 2 - Using Python:

# In the folder where the index.html file is located
python3 -m http.server 8000

Access: http://localhost:8000

Option 3 - Using http-server (Node.js):

npm install -g http-server
http-server -p 8000

Access: http://localhost:8000

3. Testing

  • Open the frontend in multiple browser tabs
  • Type messages and see real-time communication between tabs
  • Check the backend console to see connections and messages being received

About

Simple chat application using websockets

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors