Build a chat UI that survives real networks: optimistic sends with client ids, retry without duplicates, smart auto-scroll, reconnect-and-resume, accessible live updates, and a transport you can swap for WebSockets.
What you'll build
A chat UI where messages never vanish or duplicate, with reconnects, retries, and accessible live updates.
Chat looks simple: a list and an input. The hard parts are everything around it, and they're the same problems you'll meet in any real-time product (comments, notifications, collaborative editors, trading screens):
You'll build a chat UI that handles all of them, against a mock server that misbehaves on purpose: latency, 20% failed sends, other people talking, and a button to drop the connection.
1data.js sample messages (step 2 only)
2messages.js pure message-list logic: add, receive, dedupe, order, fail
3mockServer.js the misbehaving server (stands in for a WebSocket backend)
4useChat.js the data layer: history, live updates, sending, retry, resume
5useAutoScroll.js scroll only when the reader is following along
6MessageItem.jsx one message, with pending and failed states
7Composer.jsx the input form
8App.jsx wires it togetherWhat you'll learn: optimistic UI with client ids, idempotent message handling, subscription effects and cleanup, scroll anchoring, reconnect-and-resume, and accessible live regions. At the end you'll swap the mock for a real WebSocket transport without touching the UI.