# `PhoenixDatastar.StreamPlug`
[🔗](https://github.com/RicoTrevisan/phoenix_datastar/blob/v0.2.0/lib/stream_plug.ex#L1)

Global stream endpoint for Datastar live sessions.

Handles `POST /__datastar/stream?token=...` requests. Verifies the stream token
(using Phoenix.Token-based signing), subscribes to the session's GenServer, and
enters the SSE loop (`PhoenixDatastar.Server.enter_loop/2`).

Returns 401 if the token is missing or invalid. Returns 409 if the GenServer
is no longer running (e.g., session expired), signaling the client to reload.

## Expected route

    post "/__datastar/stream", PhoenixDatastar.StreamPlug, :stream

---

*Consult [api-reference.md](api-reference.md) for complete listing*
