A modern, real-time anonymous chat application built with vanilla JavaScript, Node.js, Express, and Socket.IO. Features a sleek black interface with parrot green accents and no authentication required.
- π Anonymous Chat: No sign-up or authentication required
- π¨ Modern UI: Clean black background with parrot green accents
- β‘ Real-time Messaging: Instant message delivery using Socket.IO
- π Emoji Support: Built-in emoji picker with popular emojis
- π₯ User Presence: See when users join and leave the chat
- π± Responsive Design: Works perfectly on desktop and mobile
- π Timestamps: Messages show when they were sent
- π― Gender Display: Optional gender selection (M/F/O) shown in messages
- π Input Validation: Prevents empty usernames and long messages
- HTML5: Semantic markup
- CSS3: Modern styling with gradients and animations
- Vanilla JavaScript: No frameworks, pure JS
- Socket.IO Client: Real-time communication
- Node.js: JavaScript runtime
- Express.js: Web framework
- Socket.IO: Real-time bidirectional communication
- CORS: Cross-origin resource sharing
anonymous-chat/
βββ client/
β βββ index.html # Home page (username & gender input)
β βββ chat.html # Chat room UI
β βββ style.css # All styling
β βββ script.js # Frontend logic
βββ server/
β βββ index.js # Express + Socket.IO backend
β βββ package.json # Dependencies
βββ README.md
- Node.js (v14 or higher)
- npm or yarn
-
Clone the repository
git clone <repository-url> cd anonymous-chat
-
Install dependencies
cd server npm install -
Start the server
npm start # or for development with auto-restart npm run dev -
Open your browser
- Navigate to
http://localhost:3000 - Enter a username and optional gender
- Click "Join Chat Room" to start chatting!
- Navigate to
# Set environment variables
export PORT=3000
export NODE_ENV=production
# Start the server
npm start-
Deploy to Vercel
# Install Vercel CLI npm i -g vercel # Deploy from project root vercel
-
Configure environment
- Set
REACT_APP_SOCKET_URLto your backend URL
- Set
- Connect your GitHub repository to Render
- Create a new Web Service
- Configure build settings:
- Build Command:
cd server && npm install - Start Command:
cd server && npm start
- Build Command:
- Set environment variables:
PORT: 10000 (or your preferred port)NODE_ENV: production
- Connect your GitHub repository to Railway
- Deploy automatically
- Set environment variables in Railway dashboard
-
Create a Heroku app
heroku create your-chat-app
-
Deploy
git push heroku main
-
Set environment variables
heroku config:set NODE_ENV=production
| Variable | Description | Default |
|---|---|---|
PORT |
Server port | 3000 |
NODE_ENV |
Environment mode | development |
CORS_ORIGIN |
Allowed origins | * |
Edit client/style.css:
/* Primary accent color */
--accent-color: #50fa7b; /* Parrot green */
/* Background gradient */
background: linear-gradient(135deg, #000, #1a1a1a);Edit client/chat.html:
<div class="emoji-grid">
<span class="emoji" data-emoji="π">π</span>
<!-- Add more emojis here -->
</div>- Enter Username: Required field, must be filled
- Select Gender: Optional (M/F/O)
- Join Chat: Click "Join Chat Room" button
- Start Chatting: Type messages and use emoji picker
- Real-time: See messages from other users instantly
Username (Gender): Message content
Example: CuteTiger (F): what's up? π
- Input Sanitization: All user inputs are escaped to prevent XSS
- Message Length Limits: Maximum 500 characters per message
- CORS Protection: Configured for secure cross-origin requests
- No Data Persistence: Messages are not stored, ensuring privacy
-
Socket.IO connection failed
- Check if server is running
- Verify CORS settings
- Check browser console for errors
-
Messages not appearing
- Refresh the page
- Check network connectivity
- Verify Socket.IO client is loaded
-
Styling issues
- Clear browser cache
- Check CSS file path
- Verify font loading
Enable debug logging:
// In server/index.js
const io = socketIo(server, {
cors: { origin: "*" },
debug: true
});- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Socket.IO for real-time communication
- Express.js for the web framework
- Inter font family for beautiful typography
- Emoji support for enhanced user experience
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue with detailed description
- Include browser console logs if applicable
Happy Chatting! π