Have you ever wanted to build your own real-time chat app from scratch? In this post, Iβll show you how I built a simple and clean chat application using Node.js, Socket.IO, and a frontend built with HTML/CSS/JavaScript β no database required (at least for now π).
π§ Technologies Used
- Node.js + Express β backend server
- Socket.IO β real-time communication (WebSockets)
- HTML + CSS (Dark theme) β GitHub-like dark mode
- Vanilla JavaScript β frontend logic
πΌοΈ App Preview
Users join a room by entering their name, and immediately join the live chat. Messages appear on the right for your own messages, and on the left for others. Youβll also see join/leave system notifications.
π¦ Project Structure
/public
βββ index.html # Join page (username input)
βββ chat.html # Main chat interface
βββ styles.css # Custom dark styling
βββ script.js # Handles socket and UI logic
server.js # Node.js server + Socket.IO logic
π How to Run Locally
- Clone the repository:
git clone https://github.com/Mo-Ibra/simple-chat-app
cd your-repo-name
- Install dependencies:
npm install
- Start the server:
node server.js
- Open in browser:
http://localhost:3000
π‘ Features
- β Real-time messaging between users
- β Notifications when users join/leave
- β Messages styled to indicate sender
- β Logout button that redirects to the join screen
- β No backend database needed for now (session-based)
π No Database? No Problem
At this stage, all messages are held temporarily in memory and disappear on refresh. In the future, you can easily plug in MongoDB, PostgreSQL, or any database to persist data.
π Want the Code?
Hereβs the GitHub repo:
π Mo-Ibra/simple-chat-app
π¬ Final Thoughts
This was a great exercise to understand WebSocket communication and Socket.IO in a very hands-on way. Itβs perfect for beginners who want to get a feel for real-time apps.
Feel free to fork the project, add new features like emojis, typing indicators, private messaging, or even a database backend!
Thanks for reading! β€οΈ
If you found this useful, give it a β€οΈ or leave a comment below.
Top comments (0)