starfederation / datastar

A real-time hypermedia framework.
https://data-star.dev/
MIT License
698 stars 36 forks source link

Feature Request: Support plain HTTP responses #210

Open codepilotsf opened 1 day ago

codepilotsf commented 1 day ago

SSE is so cool. The ability to fire off multiple responses to the same request for example to show an optimistic update while waiting for a database operation is amazing.

But for many would-be Datastar users, I suspect this might be an extra impediment to adoption. For example, I wanted to use Datastar with AstroJS – but Astro has kind of weird support of SSE and would have required some awkward workarounds.

Imagine how much simpler the docs would be if there was no SSE setup. Just return a response and the elements with matching DOM IDs get swapped in. Other meta data like merge type and selector could be set as custom response headers.

So then for users who want the added benefits of using SSE, they could opt in – or maybe Datastar could even be smart enough to handle both plain HTTP responses and SSE responses transparently? That would be super cool.

bencroker commented 1 day ago

What backend are you using with Astro?

codepilotsf commented 20 hours ago

Astro is now full-fledged SSR framework. So the backend is Astro.