A React-based Progressive Web App (PWA) providing a modern, responsive interface for anonymous and authenticated messaging. Features real-time message delivery, link-based conversation access, and works seamlessly across all devices.
This frontend application provides a complete messaging experience with:
- Anonymous participation via shared conversation links
- Optional user authentication for creating conversations
- Real-time message updates via Socket.IO
- Image upload and display support
- Progressive Web App capabilities (installable, offline-capable)
- Responsive design for mobile and desktop
- Conversation management and settings
- Zero Barrier Entry: Join conversations via link without creating an account
- Real-Time Messaging: Instant message delivery using Socket.IO
- User Authentication: Optional login for conversation creators
- Link Sharing: Share conversation URLs for easy access
- Anonymous Messaging: Participate without authentication using display names
- Image Support: View and send image messages (when enabled)
- Auto-Deletion Notice: See when conversations will be deleted (30-day inactivity)
- PWA Support: Install as standalone app on mobile and desktop
- Responsive Design: Optimized for all screen sizes
- Dark/Light Mode: Adaptive UI themes (if implemented)
- Framework: React 18
- Build Tool: Vite
- Language: TypeScript / JavaScript
- Real-time: Socket.IO Client
- HTTP Client: Axios / Fetch API
- Routing: React Router
- Styling:Styled Components
- PWA: Service Workers, Web App Manifest
- Node.js 24 or higher
- npm or yarn package manager
- Running backend service (API server)
Create a .env file in the root directory with these variables:
| Variable | Description | Default | Required |
|---|---|---|---|
| VITE_API_BASE_URL | Backend API base URL | http://localhost:8000 | Yes |
| VITE_APP_NAME | Application display name | Web Messages | No |
Note: Vite requires environment variables to be prefixed with VITE_ to be exposed to the client.
Install dependencies:
npm installRun with hot module replacement (HMR):
npm run devThe application will start on http://localhost:3000 (or next available port).
Changes to source files will be reflected immediately in the browser.
Build the optimized production bundle:
npm run buildThe built files will be in the dist/ directory.
Preview the production build locally:
npm run previewThis serves the built files from dist/ directory.
Build the development Docker image:
docker build -f Dockerfile.dev -t messages-pwa-dev .Run the development container:
docker run -p 3000:3000 \
-e VITE_API_BASE_URL=http://localhost:8000 \
-e VITE_APP_NAME="Web Messages" \
messages-pwa-devBuild the production Docker image:
docker build -t messages-pwa .Run the production container:
docker run -p 3000:3000 \
-e VITE_API_BASE_URL=http://localhost:8000 \
-e VITE_APP_NAME="Web Messages" \
messages-pwaUsers can access any conversation via a shared link without creating an account:
- Navigate to conversation URL (e.g.,
/conversation/:convoId) - Enter display name and select avatar
- Start sending messages immediately
Registered users can:
- Create new conversations
- Manage their conversations
- Access conversations across devices
- Reset passwords via email
Socket.IO integration provides:
- Instant message delivery
- Typing indicators (if implemented)
- Online presence (if implemented)
- Automatic reconnection
PWA features include:
- Install prompt for standalone app experience
- Offline message viewing (if service worker configured)
- App-like navigation and UI
- Push notifications (if implemented)
The application connects to the backend service via:
HTTP Requests (REST API):
- User authentication (signup, login, refresh)
- Conversation metadata
- Message history pagination
WebSocket (Socket.IO):
- Real-time message delivery
- Live conversation updates
- Presence information
Vite provides instant feedback during development:
- Edit React components → Browser updates automatically
- Edit CSS → Styles update without page reload
- TypeScript type checking in real-time
Use .env.local for local development overrides:
# .env.local
VITE_API_BASE_URL=http://localhost:8001
VITE_APP_NAME="My Chat App"Run code quality checks:
# Lint code (if configured)
npm run lint
# Format code (if using Prettier)
npm run formatVite automatically optimizes production builds:
- Code splitting for faster initial load
- Tree shaking to remove unused code
- Asset compression and minification
- CSS optimization
After running npm run build, the dist/ directory contains:
index.html- Entry pointassets/- Optimized JS, CSS, and imagesmanifest.json- PWA manifest- Service worker files (if configured)
Deploy the dist/ directory to:
- Static hosting (Netlify, Vercel, GitHub Pages)
- CDN (Cloudflare Pages, AWS CloudFront)
- Web servers (nginx, Apache)
- Container platforms (Docker, Kubernetes)
server {
listen 80;
server_name your-domain.com;
root /var/www/messages-pwa/dist;
index index.html;
# Route all requests to index.html for SPA routing
location / {
try_files $uri $uri/ /index.html;
}
# Cache static assets
location /assets/ {
expires 1y;
add_header Cache-Control "public, immutable";
}
}If the app can't connect to the backend:
-
Verify
VITE_API_BASE_URLis correct:echo $VITE_API_BASE_URL
-
Check backend is running:
curl http://localhost:8000/health-check
-
Verify CORS is configured on backend to allow frontend origin
If real-time messaging doesn't work:
- Check browser console for Socket.IO errors
- Verify WebSocket connection in Network tab
- Ensure backend Socket.IO is running
- Check firewall/proxy WebSocket support
If build fails:
-
Clear node_modules and reinstall:
rm -rf node_modules package-lock.json npm install
-
Clear Vite cache:
rm -rf node_modules/.vite
-
Check for TypeScript errors:
npm run build 2>&1 | grep "error TS"
Change the dev server port:
# In vite.config.ts
export default {
server: {
port: 3001
}
}Or use environment variable:
PORT=3001 npm run devRemember:
- Vite variables must start with
VITE_ - Restart dev server after changing
.env - Environment variables are embedded at build time
- Use
import.meta.env.VITE_API_BASE_URLin code
Edit manifest.json to customize:
- App name and description
- Icons and splash screens
- Theme colors
- Display mode (standalone, fullscreen)
Configure caching strategies:
- API responses
- Static assets
- Offline fallback page
The app can prompt users to install:
- Appears after engagement criteria met
- Shows native install dialog
- Works on iOS, Android, desktop
- Never expose API keys or secrets in frontend code
- Validate and sanitize user input
- Use HTTPS in production
- Implement Content Security Policy (CSP)
- Keep dependencies updated
- Use environment variables for configuration
- Lazy load routes with React.lazy()
- Optimize images (WebP format, proper sizing)
- Use React.memo() for expensive components
- Implement virtual scrolling for long message lists
- Debounce search and input handlers
- Monitor bundle size with Vite build analyzer
Supports modern browsers:
- Chrome/Edge 90+
- Firefox 88+
- Safari 14+
- iOS Safari 14+
- Chrome Android 90+
For older browser support, configure Babel and add polyfills.
When contributing:
- Follow existing code style
- Write descriptive commit messages
- Test on multiple devices/browsers
- Update documentation for new features
- Ensure builds pass before submitting
Refer to the LICENSE file in the repository for licensing information.