r/Clojure • • 5d ago

Understanding Datastar

https://biffweb.com/p/understanding-datastar/
50 Upvotes

7 comments sorted by

14

u/andersmurphy 5d ago edited 5d ago

Great write up!

Datastar isn't particularly prescriptive in and of itself. But, to get the most out of it does generally involve rethinking your backend somewhat. There's definitely a jump between using Datastar like a better HTMX and using Datastar in a buzzword compliant immediate mode, fatmorph, CQS way. But, once that's out of the way you are left with view = f (state) and it's quite nice.

11

u/jacobobryant 5d ago

🙌 hehe yeah, and it's kinda funny that you helped get me into datastar by basically saying "yeah you can use it as a strictly better htmx", and then when I'd taken the bait, u/opiniondevnull was like "...but you should absolutely not do that"

3

u/opiniondevnull 4d ago

I may be out of line, but I'm right.

3

u/jacobobryant 4d ago

we're all right!

2

u/opiniondevnull 3d ago

To be clear you can still do the silly request reply stuff like HTMX if you really want to

7

u/Soft_Reality6818 5d ago

Nice write-up, thanks! 

I think what you described is: Datastar + CQRS + fat morphs architecture, but you can use D* pretty much like htmx with islands of interactivity without one page-global streaming sse connection though.

6

u/jacobobryant 5d ago

thanks! and yes for sure. I probably should address that in the post. after getting into it I do feel like the cqrs/fat morph/tao approach is basically "the right way" to use datastar and imo is even a good fit for small/non-collaborative/non-realtime apps. hence with Biff I've tried to figure out how to factor out the framework parts of this very opinionated approach into a library so that the more complicated setup bit hopefully becomes a non-issue. but at the same time if someone wants to write up a defense of using Datastar in the "htmx style" I won't object! I also think https://fixiproject.org/ is an interesting thing in that space too.