You don’t need React, Vue, or Svelte to build a snappy, modern-feeling web app. By combining Server-Sent Events (SSE) for efficient one-way real-time updates with targeted partial DOM replacement, you can deliver that smooth single-page experience — without the framework bundle, the hydration penalty, or the complex client-side state management.
This architecture follows a clean, traceable flow:
Browser → API → Action → Internal Event Hub → SSE Server → Browser → Patch DOM
Let’s walk through it end-to-end.
🏗️ The Architecture, Layer by Layer
1️⃣ Browser — Connect Once, Stay Connected
The browser establishes a single long-lived SSE connection on page load. User interactions send lightweight JSON over standard HTTP — no WebSocket handshake complexity. When events arrive, only the relevant parts of the page update.
// Establish SSE connection once — persists across updates const eventSource = new EventSource('/api/events/stream'); // Handle incoming updates eventSource.addEventListener('item-updated', (event) => { const data = JSON.parse(event.data); replaceElement(`#item-${data.id}`, data.html); }); // Send action to server — plain fetch, no reload async function updateItem(id, newValue) { await fetch('/api/items/update', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ id, value: newValue }) }); } // Ultra-light partial DOM renderer function replaceElement(selector, newHtml) { const el = document.querySelector(selector); if (el) el.outerHTML = newHtml; } Key benefits: One persistent connection, tiny payloads, and zero framework overhead. Works in every modern browser.
2️⃣ API Layer — Validate, Then Forward
This is a thin, stateless HTTP handler. Its only jobs: authenticate the request, validate the input, and hand it into your internal system — then respond immediately.
Browser POST → /api/items/update ↳ ✅ Authenticate user ↳ ✅ Validate payload ↳ 📤 Publish command to event hub ↳ 202 Accepted → Return to browser Returning 202 Accepted is important — the browser doesn't block waiting for backend processing. The update arrives separately over the SSE stream once complete.
3️⃣ Action Layer — Pure Business Logic
Here’s where your domain logic lives — completely decoupled from HTTP, browsers, or SSE. A command comes in; business logic executes; state changes; a domain event is emitted to describe what happened.
Command Consumed → Run Logic → Update Database → Emit Event Because this layer knows nothing about transport, the same logic is reusable across APIs, CLI tools, background jobs — anywhere.
4️⃣ Internal Event Hub — The Nervous System
A lightweight pub/sub bus — Redis, NATS, Postgres LISTEN/NOTIFY, or even an in-memory bus for smaller deployments. It decouples the source of change from who needs to know about it.
Action Layer emits event → Event Hub broadcasts → SSE Server consumes This is what unlocks horizontal scaling. Run multiple backend instances behind a load balancer — the event hub ensures every relevant SSE connection gets the event, regardless of which instance the browser connected to.
5️⃣ SSE Server — Route and Stream
This service subscribes to the event hub, maps internal events to active user sessions, and formats messages into the simple SSE protocol:
event: item-updated id: 1733436000 data: {"id":42,"html":"<div class='item'>Updated content</div>"} Core responsibilities:
- Track which user sessions are listening
- Serialize events correctly
- Re-authenticate on stream initiation
- Send periodic
: keep-alive\n\ncomments to prevent connection timeouts - Use
Last-Event-IDduring reconnection to replay missed messages
💡 Pro tip: Never push full pages through SSE — only the HTML fragment or JSON needed to render the change. Keep updates under 1KB whenever possible.
6️⃣ Back to the Browser — Partial DOM Update
When the SSE message lands, your JavaScript updates only the affected element. Navigation, forms, layout — everything else stays exactly where it is. No spinners, no flash of blank content, no full-page re-render.
eventSource.addEventListener('stats-refreshed', (e) => { document.querySelector('#stats-panel').innerHTML = e.data; }); 🔁 The Full Flow in One Table
| # | From → To | What Happens |
|---|---|---|
| 1 | Browser → API | User interacts; sends lightweight JSON |
| 2 | API → Event Hub | Request validated; published as a command |
| 3 | Hub → Action | Command consumed; logic runs; state updates; event emitted |
| 4 | Hub → SSE Server | Event routed to the correct user session |
| 5 | SSE → Browser | Event sent over the persistent stream |
| 6 | Browser → DOM | One targeted element is replaced — page stays live |
✅ Why This Approach Shines
- No hydration tax — First load is plain, server-rendered HTML. JS only patches changes afterward.
- Instant feel — Navigation is server-fast; updates arrive over an already-open connection.
- Tiny footprint — The entire client-side update engine fits in ~20 lines of JavaScript.
- Graceful degradation — Without JavaScript, forms and links still work — they just fall back to standard page reloads.
- SEO friendly — Search engines see your fully rendered page content immediately.
- Simple mental model — Data flows one way. Events are traceable. No useEffect surprises or context chains to untangle.
⚡ Best Fit — And Where to Look Elsewhere
✅ Great for:
- Dashboards and status displays
- Live-updating feeds and search results
- Multi-user collaborative views
- Admin interfaces and internal tools
- Content-heavy sites with dynamic sections
❌ Less ideal for:
- Complex drag-and-drop interfaces
- Canvas or WebGL-heavy applications
- Frequent bidirectional messaging — WebSockets are a better fit there
- Apps that need full client-side routing with no server involvement
🛡️ Quick Security & Reliability Notes
- Always authenticate the
/events/streamendpoint — it’s public by default otherwise - Use
POSTnotGETfor state-changing actions - Build for reconnections — SSE clients will reconnect automatically; make your handlers idempotent
- Include a reconnection timeout with exponential backoff in your logic if needed
- Respect
Last-Event-ID— it’s how browsers tell you what they missed when reconnecting
💭 Closing Thoughts
We often reach for heavy frameworks because they solve problems for us — but many of those problems are problems the frameworks themselves created. This pattern leans into what the web platform already does well: HTTP for actions, long-lived connections for updates, and DOM APIs for rendering. You get that snappy, modern SPA experience — but your code stays simple, your bundles stay small, and your mental model stays clear.
Sometimes the most powerful framework is the one you didn't ship.