Do you want to build your own real-time chat application? Inspired by hack.chat, this Node.js application lets you create private chat rooms with file sharing, message logging, and more—without needing accounts or external dependencies.
This project is a hack.chat-inspired chat application written in Node.js. It requires no accounts, stores no permanent logs (messages can be configured to disappear), and supports file sharing within chat rooms.
What You’ll Learn
- How to install and set up the chat application
- How to create and join chat rooms
- How to use features like file sharing and invisible mode
- How to customize and deploy the application
Key Features
📖 1. Custom Chat Rooms via URL
Join any chat room directly using a URL format:
http://yourdomain.com/username/roomname
For example, http://yourdomain.com/rafi/krafichatroom1 automatically joins “rafi” to “krafichatroom1”.
📖 2. Real-Time Messaging
Send and receive messages instantly. Each message displays:
- Sender’s username
- Timestamp
- Message content
📖 3. File Sharing
Upload and share files directly in the chat:
- Images can be viewed inline with a “View” button
- Other files are shared via download links
📖 4. Active User List
See who’s currently in the chat room. The user list updates in real-time as users join and leave.
📖 5. Message Logging
All messages are logged to files in the chat_log/ directory:
- Logs are appended (not overwritten)
- File format:
{roomname}_log.txt - Useful for reviewing past conversations
📖 6. Invisible Mode
A unique privacy feature:
- Click “Toggle Invisible Mode” to hide the chat
- Chat window goes blank
- Return by typing the secret key:
zx
📖 7. Built-in Image Viewer
Click “View” on shared images to open them in an overlay within the chat—no need to download.
Installation
Step 1: Clone the Repository
git clone https://gitlab.com/krafi/krafi.hack.chat.git
cd krafi.hack.chat
Step 2: Install Dependencies
npm install express http socket.io multer
Step 3: Start the Server
npm start
The server runs on port 3000 by default. Access it at http://localhost:3000
Directory Structure
krafi.hack.chat/
├── public/ # Static files (HTML, CSS, JS)
├── uploads/ # User-uploaded files
├── chat_log/ # Message log files
├── server.js # Main server file
└── package.json # Dependencies
How to Use
Step 1: Access the Application
Open your browser and navigate to:
http://localhost:3000
Step 2: Join a Chat Room
On the landing page:
- Enter your username
- Enter a room name (or use a custom URL)
- Click “Join”
Step 3: Send Messages
- Type in the message box
- Press Enter or click “Send” to send
- Messages appear instantly for all users
Step 4: Share Files
- Click the file attachment button
- Select a file to upload
- For images, click “View” to preview inline
Step 5: Use Invisible Mode
- Click “Toggle Invisible Mode”
- The chat becomes hidden
- Type
zxto return to the chat
Configuration Options
You can customize the application by editing server.js:
📖 Server Port
Change the port number:
const PORT = process.env.PORT || 3000;
📖 Upload Directory
Modify where files are stored:
const uploadDir = './uploads/';
📖 Log Directory
Change where message logs are saved:
const logDir = './chat_log/';
Deployment
Deploy on VPS/Server
- Upload files to your server
- Install Node.js on the server
- Run
npm install - Use a process manager like PM2:
npm install -g pm2 pm2 start server.js
Deploy on Cloud Platforms
This app can be deployed on:
- Railway
- Render
- Heroku
- DigitalOcean App Platform
When deploying publicly, ensure you configure proper security settings and consider adding SSL/HTTPS.
Troubleshooting
📖 Server won't start?
-
Check Node.js is installed:
node --version -
Verify dependencies are installed:
npm install -
Check if port 3000 is already in use:
lsof -i :3000
📖 Messages not appearing?
- Check your internet connection
- Verify Socket.io is connecting (check browser console)
- Refresh the page
- Ensure you’re in the same room
📖 File upload not working?
- Check the
uploads/directory exists and is writable - Verify file size limits in server.js
- Check server logs for errors
📖 User list not updating?
- Refresh the page
- Check browser console for Socket.io errors
- Ensure the user hasn’t disconnected unexpectedly
Source Code
View and contribute to the project: krafi.hack.chat on GitLab
This chat application is perfect for creating private chat rooms for friends, teams, or communities. It’s lightweight, requires no accounts, and gives you full control over your data.
Start building your real-time chat application today!
Discussion
0 commentsJoin the Discussion
Sign in to post comments and join the conversation.
No comments yet. Be the first to share your thoughts!