React (Vite) frontend for the Talker chat app, built against your existing Express backend.
npm install
cp .env.example .env # then edit VITE_API_URL if your backend isn't on localhost:3000
npm run devRuns at http://localhost:5173 by default.
Your backend needs a few small additions to support this frontend — a users
list, recent chats, CORS, a /me session-check endpoint, and basic socket
relay logic. None of your existing logic changes. See
BACKEND_PATCH.md (in the separate backend-patch folder you received) for
exact diffs.
Without that patch:
- Login/register will work, but the app won't know you're logged in after a refresh (no
/me) - The sidebar will fail to load (no
/api/usersor/api/users/recent-chats) - Messages sent via REST will save, but won't arrive live for the other person (no socket relay)
- Cross-origin requests will be blocked by the browser (no CORS)
src/
api/ axios instance + one file per resource (auth, users, messages)
context/ AuthContext (session state), SocketContext (live connection)
components/ reusable UI: Sidebar, ChatWindow, MessageBubble, Avatar, forms
pages/ LoginPage, RegisterPage, HomePage
POST /api/auth/registeris sent asmultipart/form-data(your backend requires apropicfile via multer).POST /api/auth/loginsends bothusernameandemailset to whatever the person typed, since your backend's$orquery checks both fields — this lets people log in with either.- All requests use
withCredentials: truesince your auth is cookie-based. sendMessagecallsPOST /api/chats/sendMessage/:id— note this requires the one-line route fix inBACKEND_PATCH.md(the original route was missing:id, which would silently fail every send).
- Register (with required profile photo) / Login / Logout
- Recent chats list + "People" list to start new conversations
- Send messages, delete an individual message, delete an entire chat
- Live message delivery via Socket.io (after the backend patch)
- Session persistence across page refresh