Gitpedia

ChatApplication

Real-time, room-based chat app with WebSockets — no sign-up, just pick a room ID and start chatting. Next.js 16 + React 19 + TypeScript frontend, Node.js ws backend.

From dv2202·Updated May 30, 2026·View on GitHub·

A real-time, room-based chat app with no accounts or sign-up. Pick a room ID and a username, join instantly, and chat with everyone in that room over WebSockets. The project is written primarily in TypeScript, first published in 2025. Key topics include: anonymous-chat, chat-application, nextjs, nodejs, radix-ui.

Chat Application

A real-time, room-based chat app with no accounts or sign-up. Pick a room ID and a username, join instantly, and chat with everyone in that room over WebSockets.

Features

  • Room-based chat — create or join any room by ID (e.g. team-chat, study-group)
  • No accounts — choose a display name each time you join
  • Real-time messaging — messages broadcast instantly over WebSockets
  • Live presence — every client sees the up-to-date list of users in the room
  • Username conflict prevention — the server rejects duplicate usernames in the same room
  • Identity spoofing protection — the server uses the joined username/room for outbound messages; the client's payload identity is ignored

Tech stack

LayerTechnologies
FrontendNext.js 16, React 19, TypeScript, Tailwind CSS, Zustand, Radix UI
BackendNode.js, TypeScript, ws

Project structure

ChatApplication/
├── chat-frontend/         # Next.js web app (default: http://localhost:3000)
│   ├── app/               # Pages and layout
│   ├── components/        # UI and chat components
│   └── store/             # WebSocket state (Zustand)
└── chat-backend/          # WebSocket server (ws://localhost:8080)
    └── src/index.ts       # Server logic

Prerequisites

  • Node.js 18 or newer
  • npm (included with Node.js)

Getting started

Run the backend and frontend in two separate terminals.

1. Start the WebSocket server

bash
cd chat-backend npm install npm run dev

The server listens on port 8080. You should see New connection in the console when clients connect.

2. Start the frontend

bash
cd chat-frontend npm install npm run dev

Open http://localhost:3000 in your browser.

3. Use the app

  1. Enter a room ID on the landing page.
  2. Enter a username.
  3. Click Join Room and start chatting.
  4. Open another browser tab or window with the same room ID to test multi-user chat.

WebSocket protocol

Clients connect to ws://localhost:8080 and exchange JSON messages of the shape:

json
{ "type": "<event>", "payload": { ... } }

Client → server

typepayloadDescription
join{ roomId, username }Join a room
chat{ message }Send a message to your joined room (server uses your joined username/roomId)

Server → client

typepayloadDescription
join_success{ roomId, username }Join accepted
join_error{ message }Join failed (e.g. username already taken)
room_users{ roomId, users }Updated list of usernames in the room
message{ username, message }Chat message from a user in the room
chat_error{ message }Send failed (e.g. not in a room, empty message)
error{ message }Invalid JSON or other protocol error

Scripts

Frontend (chat-frontend)

CommandDescription
npm run devStart development server
npm run buildProduction build
npm run startRun production build
npm run lintRun ESLint

Backend (chat-backend)

CommandDescription
npm run devCompile TypeScript and start the server

License

ISC

Contributors

Showing top 1 contributor by commit count.

View all contributors on GitHub →

This article is auto-generated from dv2202/ChatApplication via the GitHub API.Last fetched: 5/31/2026