This is just a stub doc for collecting any SSE related tips/tricks/considerations others in the Datastar community want to share. While it will likely serve as a helpful resource itself, the content will be used to author a more user friendly doc or artifact to reference when learning and leveraging SSE.
There are some known gotchas for SSE documented here:
Here's my thoughts on a possible way to structure it based on FAQs we see in the discord. There's probably some room to defer to other parts of the documentation or omit things, but I haven't yet taken the time to reconcile where that makes sense to me. I removed the language saying "big red warning" section since I wasn't sure if it'd always stay red in the future, or if people using assistive devices or with colorblindness would easily identify the color.
SSE FAQ
If any information here contradicts the standards or MDN, assume those are more authoratative than this FAQ.
Are SSE required to use Datastar?
No, you can use Datastar with regular http responses as long as you adjust the headers appropriately. See (link to patching elements)
Do I have to keep my SSE connection long lived?
No, SSE is just the option to provide zero or more responses. If your connection needs are complete after zero or one events are added to the stream, then terminate the connection.
Are there any SSE gotchas?
Browsers have implemented connection limits. At time of writing that's 6 open connections for HTTP1.1 and about 100 open connections for HTTP2 on most browsers. This limit is per browser per domain. (See the warning at the end of https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#listening_for_custom_events)
If you don't control the return codes from your server, you may permanently close a connection you inteded to allow to retry connecting. (see: )