react-live-chatroom
v0.1.11
Published
This is the main frontend application for the ChatSphere real-time chat platform. Built with React, TypeScript, and Vite, it provides a modern, responsive user interface for the chat functionality.
Downloads
4
Readme
ChatSphere Frontend
This is the main frontend application for the ChatSphere real-time chat platform. Built with React, TypeScript, and Vite, it provides a modern, responsive user interface for the chat functionality.
Technologies
- React: UI library
- TypeScript: For type safety
- Vite: Build tool and development server
- TailwindCSS: Utility-first CSS framework
- WebSocket: For real-time communication
- Vitest: Testing framework
Project Structure
main/
├── public/ # Static assets
├── src/
│ ├── api/ # API client utilities
│ │ ├── httpApi.ts # HTTP API client
│ │ └── websocketApi.ts # WebSocket client
│ ├── components/ # React components
│ │ ├── Chat.tsx # Main chat component
│ │ ├── MessageBubble.tsx # Message display component
│ │ └── ...
│ ├── hooks/ # Custom React hooks
│ │ ├── useChat.ts # Chat functionality hook
│ │ └── ...
│ ├── types.ts # TypeScript type definitions
│ ├── App.tsx # Main application component
│ └── main.tsx # Application entry point
├── package.json # Dependencies and scripts
└── tsconfig.json # TypeScript configurationFeatures
- Real-time Messaging: Send and receive messages instantly
- Room Management: Create and join chat rooms
- User Authentication: Secure user authentication
- API Token Management: Generate and manage API tokens
- Responsive Design: Works on desktop and mobile devices
Setup and Installation
Install dependencies:
npm installConfiguration: The package is pre-configured to connect to the Railway-hosted API and WebSocket servers.
API URL: https://react-live-chatroom-api-production.up.railway.app/api WS URL: wss://react-live-chatroom-api-production.up.railway.app/wsStart the development server:
npm run dev
Available Scripts
npm run dev: Start development servernpm run build: Build for productionnpm run test: Run testsnpm run lint: Run ESLintnpm run preview: Preview production build locally
API Integration
The frontend integrates with the ChatSphere API server for:
- User Authentication: Login and registration
- Room Management: Creating and joining rooms
- Message Handling: Sending and receiving messages
- Token Management: Generating and revoking API tokens
WebSocket Connection
Real-time messaging is implemented using WebSockets. The useChat hook manages the WebSocket connection and provides methods for sending and receiving messages.
Testing
Tests are written using Vitest and React Testing Library. Run tests with:
npm testBuilding for Production
To build the application for production:
npm run buildThis will create a dist directory with the compiled assets.
License
MIT
