htmx-stream

command
v0.33.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2026 License: MIT Imports: 6 Imported by: 0

README

HTMX + Server-Sent Events streaming

An HTMX page that subscribes to an SSE endpoint and updates a DOM element in real time as the server streams events. Demonstrates:

  • Setting the SSE response headers correctly (text/event-stream, no-cache, keep-alive).
  • Using http.Flusher to push individual events.
  • Cleanly stopping on r.Context().Done() when the client disconnects.
  • Pairing this with the htmx-sse extension on the browser side.

Run

go run ./examples/htmx-stream &
open http://localhost:8080

A random integer streams to the page every 100 ms. Close the tab and the goroutine exits — context cancellation is the only stop signal.

Notes

This example uses raw text/event-stream for direct HTMX consumption. If you also want the MCP control plane to share the same SSE primitives, see the MCP SSE guide.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL