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 bac
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 bac
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.
team-chat, study-group)username/room for outbound messages; the client's payload identity is ignored| Layer | Technologies |
|---|---|
| Frontend | Next.js 16, React 19, TypeScript, Tailwind CSS, Zustand, Radix UI |
| Backend | Node.js, TypeScript, ws |
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 logicRun the backend and frontend in two separate terminals.
cd chat-backend
npm install
npm run devThe server listens on port 8080. You should see New connection in the console when clients connect.
cd chat-frontend
npm install
npm run devOpen http://localhost:3000 in your browser.
Clients connect to ws://localhost:8080 and exchange JSON messages of the shape:
{ "type": "", "payload": { ... } }type |
payload |
Description |
|---|---|---|
join |
{ roomId, username } |
Join a room |
chat |
{ message } |
Send a message to your joined room (server uses your joined username/roomId) |
type |
payload |
Description |
|---|---|---|
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 |
chat-frontend)| Command | Description |
|---|---|
npm run dev |
Start development server |
npm run build |
Production build |
npm run start |
Run production build |
npm run lint |
Run ESLint |
chat-backend)| Command | Description |
|---|---|
npm run dev |
Compile TypeScript and start the server |
ISC
No open issues yet, or sync has not completed.