A minimal realtime chat app built on Val Town. Messages are stored in Val Town SQLite and streamed to every client over Server-Sent Events. A QR code of the app's own URL is shown in the sidebar so people can scan to join.
localStorage (prompted on first visit)Rendering mermaid diagram...
index.ts ← Hono backend: static + /api routes + SSE stream
frontend/
index.html ← HTML shell (loads Twind + React)
index.tsx ← React entrypoint (mounts <App />)
favicon.svg ← App icon
components/
App.tsx ← Username gating (localStorage)
UsernamePrompt.tsx ← First-visit username form
Chat.tsx ← Messages list, input, sidebar
QRCode.tsx ← Renders a QR of the site URL
GET / — serves the React appPOST /api/messages — { username, text } → stores a message in SQLiteGET /api/messages?sinceId=N — fetch messages newer than NGET /api/stream?sinceId=N — SSE stream of new messages (polls SQLite every
1.5s; emits hello, message, and ping events)localStorage: A first-visit prompt stores the chosen name
under the key beyond-text:username. A "change" button in the header
clears it.