Simple learning project to build a real-time chat app with websocket:
backend/: Express + WebSocket server in TypeScriptfrontend/: React + Vite client in TypeScript
This is an educational repo for learning how to connect a React app to a WebSocket backend and send messages in real-time.
- Backend accepts WebSocket clients, broadcasts messages, and handles basic connection events.
- Frontend connects to the backend and shows live updates in the UI.
- Node.js and Bun installed.
- Recommend using Bun for running tasks (as requested):
bun install,bun run.
- Open a terminal.
cd backend- Install dependencies:
bun install
- Start server:
bun run dev
The server should be running on http://localhost:3000 (or the port defined in backend/server.ts).
- Open another terminal.
cd frontend- Install dependencies:
bun install
- Start dev server:
bun run dev
Vite frontend should open at http://localhost:5173 (or the port shown in the terminal).
- Open frontend in browser.
- Connect to backend via WebSocket as app UI says.
- Send/receive messages, verify broadcast and updates.
- Stop backend and frontend with
Ctrl+C. - Optional:
bun installin each folder again if you change dependencies.
- If scripts differ (for example
devis not defined), usebun run <script>frompackage.json. - If using npm/yarn is preferred, run
npm install/npm run devoryarn/yarn devinstead.
