You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(docs): replace JS EventSource with HTMX SSE extension in Litestar guide
The framework uses HTMX for client-side interaction — the SSE section
was incorrectly showing raw JavaScript. Replaced with HTMX sse-connect
/ sse-swap markup consistent with the zero-JS philosophy.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
<p>A minimal browser snippet to consume the SSE stream and swap partial HTML. HTMX SSE extension handles this automatically if you prefer a zero-JS approach.</p>
790
+
<h3id="sse-client">Client-side with HTMX SSE</h3>
791
+
<p>The framework uses HTMX for all client-side interaction. HTMX's built-in <ahref="https://htmx.org/extensions/sse/" target="_blank" rel="noopener">SSE extension</a> handles the stream connection and DOM swapping — no custom JavaScript required.</p>
<spanclass="cm"><!-- Each SSE frame replaces this content --></span>
808
+
<p>Generating report&hellip;</p>
809
+
</div></code></pre>
808
810
</div>
809
811
810
-
<divclass="callout callout--warn">
811
-
<strong>Browser connection limit.</strong>Each <code>EventSource</code>holds one HTTP/1.1 connection. Modern browsers cap concurrent connections per origin at 6. Prefer HTTP/2 in production (Litestar + uvicorn with <code>--http h2</code>) to avoid this ceiling.
812
+
<divclass="callout callout--insight">
813
+
<strong>Zero JavaScript.</strong>HTMX's SSE extension opens the connection, receives each <code>data:</code>frame from <code>StreamingComponent</code>, and swaps the rendered HTML into the target element automatically. This is consistent with the framework's server-driven, minimal-JS philosophy.
812
814
</div>
813
815
814
816
<!-- WEBSOCKET -->
@@ -922,7 +924,7 @@ <h2 id="full-example" data-n="06">Full Example App</h2>
922
924
<li><spanclass="step-text">Open <code>http://localhost:8000</code> — the index page renders all three components server-side.</span></li>
923
925
<li><spanclass="step-text">Click Increment / Decrement on the counter — each click POSTs to <code>/components/counter/</code> and swaps the HTML fragment.</span></li>
924
926
<li><spanclass="step-text">Submit text in the sentiment box — the async handler awaits the (mock) ML service and re-renders the score badge.</span></li>
925
-
<li><spanclass="step-text">Click Generate Report — an <code>EventSource</code> opens to <code>/components/report/stream/</code> and each section appears as it completes.</span></li>
927
+
<li><spanclass="step-text">Click Generate Report — HTMX's SSE extension connects to <code>/components/report/stream/</code> and each section appears as it completes.</span></li>
0 commit comments