A beautiful, minimalist real-time chat application where users can see each other's typing character-by-character instantly. Built with Next.js 14, Socket.IO, and Tailwind CSS.
- โก Real-time typing synchronization - See every keystroke instantly
- ๐ Two-way communication - Both users can type simultaneously
- ๐ฑ Responsive design - Side-by-side on desktop, stacked on mobile
- ๐จ Beautiful UI - Clean, modern interface with smooth animations
- ๐ Shareable sessions - Generate unique session links to invite others
- ๐ซ No registration - Start chatting immediately without accounts
- ๐ Connection status - Real-time indicators and user presence
- ๐งน Ephemeral sessions - Automatic cleanup of inactive sessions
- Frontend: Next.js 14 (App Router), React, TypeScript
- Styling: Tailwind CSS, shadcn/ui components
- Real-time: Socket.IO
- Backend: Node.js, Express
- Icons: Lucide React
- Deployment: Vercel (frontend), Railway (WebSocket server)
This app uses a separate deployment strategy:
- Frontend: Static Next.js app deployed to Vercel/Netlify
- WebSocket Server: Node.js server deployed to Railway
- Node.js 16+
- npm or yarn
-
Clone the repository
git clone <your-repo-url> cd realtime-chat-app
-
Install dependencies
npm install
-
Start the WebSocket server (in server directory)
cd server npm install npm run dev -
Start the Next.js development server (in root directory)
npm run dev
-
Open your browser
- Frontend: http://localhost:3000
- WebSocket server health: http://localhost:3001/health
- Create a new Railway project
- Connect your GitHub repository
- Set the Root Directory to
server - Railway will automatically detect the Node.js app
- Set environment variables:
NODE_ENV=productionFRONTEND_URL=https://your-frontend-domain.com(optional)
- Deploy and note the Railway URL (e.g.,
https://your-app.up.railway.app)
- Push your code to GitHub
- Connect your repository to Vercel
- Vercel will automatically detect the Next.js app
- The frontend will be deployed as a static site
- No environment variables needed (WebSocket URL is hardcoded)
If your Railway URL is different, update the WebSocket URL in:
app/chat/[sessionId]/page.tsx line 32:
const socketUrl = 'https://your-railway-app.up.railway.app';Frontend: No environment variables needed
Backend (Railway):
NODE_ENV=production
PORT=3001
FRONTEND_URL=https://your-frontend-domain.com
โโโ app/ # Next.js app directory
โ โโโ chat/[sessionId]/ # Dynamic chat page
โ โโโ globals.css # Global styles
โ โโโ layout.tsx # Root layout
โ โโโ page.tsx # Landing page
โโโ components/ # Reusable components
โ โโโ ui/ # shadcn/ui components
โโโ lib/ # Utility functions
โโโ server/ # WebSocket server (separate deployment)
โ โโโ index.js # Server implementation
โ โโโ package.json # Server dependencies
โโโ README.md
- Session Creation: Users create a unique session ID or join an existing one
- Real-time Connection: Socket.IO establishes WebSocket connection to Railway server
- Typing Sync: Every keystroke is immediately broadcast to connected users
- User Management: Server tracks active users and their typing status
- Session Cleanup: Inactive sessions are automatically cleaned up
- Check that the Railway WebSocket server is running
- Verify the WebSocket URL in the frontend code
- Check browser console for connection errors
- Test the health endpoint:
https://your-railway-app.up.railway.app/health
- Ensure Root Directory is set to
server - Check that
package.jsonexists in the server directory - Verify environment variables are set correctly
- Check Railway logs for server errors
- Chrome/Edge 90+
- Firefox 88+
- Safari 14+
- Mobile browsers with WebSocket support
- Optimized for low latency
- Efficient WebSocket message handling
- Automatic cleanup of inactive sessions
- Client-side debouncing for typing indicators
- CORS properly configured
- No data persistence (ephemeral sessions)
- Rate limiting ready for production
- Environment-based configuration
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
MIT License - feel free to use this project for personal or commercial purposes.