A real-time video chat application that connects random strangers for anonymous conversations. Built with modern web technologies for a smooth and engaging user experience.
- Anonymous Chat: Connect with random strangers without any sign-up or identity verification
- Real-time Video Communication: Powered by Zego Cloud's UI Kit Prebuilt
- Text Chat: Text messaging alongside video calls
- Smart Matching: Automatic pairing system that matches users seeking to chat
- Responsive Design: Works seamlessly on mobile, tablet, and desktop devices
- Dynamic UI States: Smooth transitions between idle, waiting, and chatting states
- Next User: Skip current partner and connect with another random user
- Partner Disconnect Detection: Automatically handles when a partner leaves the chat
- Next.js 16.1 - React framework with App Router
- React 19 - UI library
- TypeScript 5 - Type safety
- Tailwind CSS 4 - Utility-first CSS framework
- Motion (Framer Motion) - Animation library
- Lucide React - Icon library
- Socket.IO Client - Real-time communication
- Zego Cloud UI Kit - Video call infrastructure
- Node.js - JavaScript runtime
- Socket.IO - WebSocket communication
- UUID - Unique identifier generation
- Nodemon - Development server with hot reload
- dotenv - Environment variable management
random_chat/
├── public/ # Static assets
├── src/
│ ├── app/
│ │ ├── page.tsx # Home page with chat flow logic
│ │ ├── layout.tsx # Root layout wrapper
│ │ └── globals.css # Global styles
│ ├── components/
│ │ ├── Navbar.tsx # Navigation bar (hidden during chat)
│ │ ├── Footer.tsx # Footer component (hidden during chat)
│ │ └── VideoRoom.tsx # Video call component using Zego
│ └── ...
├── eslint.config.mjs
├── next.config.ts
├── tsconfig.json
├── tailwind.config.js
├── package.json
└── README.md
socket/
├── index.js # Socket.IO server with chat logic
├── package.json
└── .env # Environment variables (not included)
-
Idle State
- User sees welcome screen with "Start Anonymous Chat" button
- Navbar and Footer are visible
- User can initiate a chat by clicking the button
-
Waiting State
- Animated loader with "Waiting for a match..." message
- Server queues the user in the waiting list
- Navbar and Footer remain visible
- Waiting for another user to join
-
Chatting State
- Full-screen video call interface
- Header with "Random Chat | Connected" status
- "Next" button to skip current user
- VideoRoom component displaying the video call
- Navbar and Footer are hidden
- Text chat available in the video interface
start- User initiates a chat connectionnext- User wants to skip current partner and find another
matched- Server sends matched room ID to both userswaiting- Server confirms user is in waiting queuepartnerLeft- Server notifies when chat partner disconnects
- Node.js (v18+)
- npm or yarn
-
Clone the repository
git clone <repository-url> cd Chat
-
Install Frontend Dependencies
cd random_chat npm install -
Install Backend Dependencies
cd ../socket npm install -
Environment Variables
Create
.env.localinrandom_chat/:NEXT_PUBLIC_SOCKET_URL=http://localhost:5000 NEXT_PUBLIC_ZEGO_APP_ID=your_zego_app_id NEXT_PUBLIC_ZEGO_SERVER_SECRET=your_zego_server_secretCreate
.envinsocket/:PORT=5000
-
Start Socket.IO Server
cd socket npm run dev -
Start Next.js Development Server (in another terminal)
cd random_chat npm run dev -
Open the application
- Navigate to
http://localhost:3000in your browser - Open multiple tabs/windows to test the chat functionality
- Navigate to
The application is fully responsive:
- Mobile (< 640px): Optimized touch interface, compact headers
- Tablet (640px - 1024px): Balanced layout
- Desktop (> 1024px): Full-featured UI with all elements visible
- Navigation bar visible during idle and waiting states
- Hides during active chat
- Copyright and app info footer
- Hides during active chat to maximize video area
- Wrapper for Zego Cloud video call interface
- Handles token generation and room setup
- Manages video call configuration (1-on-1 mode, text chat enabled)
- Manages application state (idle/waiting/chatting)
- Handles socket connections and events
- Implements smooth animations between states
- Generates unique user IDs and room IDs
- Smooth Animations: Framer Motion powers all transitions
- Glassmorphism Design: Modern blur effects and transparency
- Gradient Backgrounds: Purple and blue gradients for visual appeal
- Loading States: Animated loader during matchmaking
- Icon Integration: Lucide icons for intuitive actions
npm run dev
npm run devVishal Prajapati
Enjoy anonymous conversations responsibly! 🎉