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
After evaluating HTMX SSE extension (htmx-ext-sse) as the integration path, the conclusion is that it adds unnecessary complexity for Facet's use cases:
The fallback pattern (SSE as trigger + hx-get) works but introduces a double round-trip
For high-frequency event flows, SSR is the wrong tool regardless
The browser's native EventSource API is sufficient, requires no external libraries, and keeps the client-side code straightforward.
What this issue covers
Document how to consume RESTHeart SSE endpoints from Facet templates using plain JavaScript and the native EventSource API. No HTMX SSE extension needed.
Recommended pattern
<tbodyid="product-list">
{% for doc in documents %}
<tr>...</tr>
{% endfor %}
</tbody><script>constsource=newEventSource('/mydb/products/_streams/changes');source.addEventListener('change',()=>{// Use HTMX to re-fetch and re-render the fragmenthtmx.ajax('GET','/mydb/products',{target: '#product-list',swap: 'outerHTML'});});source.onerror=()=>source.close();</script>
The EventSource handles reconnection automatically. The htmx.ajax() call is optional — plain fetch() + DOM manipulation works equally well for simpler cases.
Deliverables
SSE section in docs/DEVELOPERS_GUIDE.md covering:
Brief explanation of EventSource API (connect, listen, close, auto-reconnect)
RESTHeart SSE endpoint format (/_streams/<name>)
The pattern above with a full example
When to use SSE vs polling
Auth considerations (cookies sent automatically same-origin; query param for JWT)
Note on high-frequency flows: use client-side rendering, not SSR
Conclusion of analysis
After evaluating HTMX SSE extension (
htmx-ext-sse) as the integration path, the conclusion is that it adds unnecessary complexity for Facet's use cases:sse-swapwith HTML payloads requires server-side per-event interception, which RESTHeart does not currently support (see Feature request: per-event SSE interceptor plugin type restheart#599)hx-get) works but introduces a double round-tripThe browser's native
EventSourceAPI is sufficient, requires no external libraries, and keeps the client-side code straightforward.What this issue covers
Document how to consume RESTHeart SSE endpoints from Facet templates using plain JavaScript and the native
EventSourceAPI. No HTMX SSE extension needed.Recommended pattern
The
EventSourcehandles reconnection automatically. Thehtmx.ajax()call is optional — plainfetch()+ DOM manipulation works equally well for simpler cases.Deliverables
SSE section in
docs/DEVELOPERS_GUIDE.mdcovering:EventSourceAPI (connect, listen, close, auto-reconnect)/_streams/<name>)Working example in
examples/product-catalog(tracked in Docs & example: SSE live updates via native EventSource API #7)What is out of scope
htmx-ext-sse)Acceptance criteria