This is a real-time chat application built using React, Vite, Express, and Socket.io. The application allows users to connect, send messages, and see real-time typing indicators.
- Real-time messaging
- User connection/disconnection notifications
- Typing indicators
- Unique user identification
- Responsive design
- React
- Vite
- Socket.io Client
- Tailwind CSS
- Node.js
- Express
- Socket.io
- CORS
- Node.js (v14 or later)
- npm or yarn
git clone https://your-repository-url.git
cd your-project-name
cd server
npm install
cd ../client
npm install
cd server
npm start
cd client
npm run dev
Open http://localhost:5173 in your browser
project-root/
│
├── client/ # React frontend
│ ├── src/
│ │ ├── components/
│ │ ├── context/
│ │ ├── App.tsx
│ │ └── main.tsx
│
└── server/ # Express backend
├── index.js
└── package.json
Frontend
- SocketContext: Manages Socket.io connection
- Chat Component: Renders chat interface and handles messaging
Backend
Socket.io Event Handlers:
- connection: Handles new user connections
- message: Broadcasts messages to all users
- activity: Manages typing indicators
- userDisconnected: Handles user disconnections