Any practical experience using #HTMX over #react for #js web dev?
-
-
Ben Pate π€π»replied to Chris K Wensel last edited by
@cwensel Not react, but I used Angular to make a pretty big app. Once I discovered #htmx, there was no going back. Welcome to the party
Htmx is a big shift in how you think about the web. It returns control to your server, so youβll need a really good HTML rendering engine for your server-side environment.
And, ignore the JavaScript naysayers who say itβs slow, wonβt scale, whatever. Htmx performs fantastically, and has been far easier to organize than anything I did in JS.
-
Chris K Wenselreplied to Ben Pate π€π» last edited by
@benpate nice! Thanks for sharing
-
Felix πΊπ¦π΄ββοΈreplied to Chris K Wensel last edited by
@cwensel @benpate Don't let the horse tell you. There are always several tools to do a job well. #htmx is good for many things, but sometimes it makes sense to move more logic to the client side. I already have Angular and React etc. used too for large projects. These frameworks or libraries can make sense. Currently, however, I also use htmx for one project and #alpinejs for more complex things in the same project.
But it always depends on the -
Felix πΊπ¦π΄ββοΈreplied to Felix πΊπ¦π΄ββοΈ last edited by
-
Ben Pate π€π»replied to Felix πΊπ¦π΄ββοΈ last edited by
@leobm @cwensel Oh for sure. Use the right tool for the job -- and thereβs plenty of areas where htmx is totally the wrong tool.
I think Iβm saying the same thing as you, just from a different angle. Iβve met lots of devs who canβt see past the Angular/React/Vue to even consider anything else.
Iβm building primarily in htmx, with various JS tool to augment the things that should obviously be done in the client (like playing music. Who plays music on the server??)
-
Felix πΊπ¦π΄ββοΈreplied to Ben Pate π€π» last edited by
@benpate @cwensel Ok, as has already been said htmx is a really interesting approach. However, you should use a good template engine, even if you can create something like components in it (i.e. your own tag where you can set attributes). What I personally find important is to also think about the paths for http requests. When you work with json, you think in terms of resources, which is not really the case with htmx anymore. I haven't
-
Felix πΊπ¦π΄ββοΈreplied to Felix πΊπ¦π΄ββοΈ last edited by
@benpate @cwensel found a really good approach yet. I'm trying to think along the lines of atomic design. So in (atoms), (Molecules), Organisms, Templates and Pages. And then to reflect this in the URL path. But perhaps there are better approaches. I simply comitted myself to something like this.
In any case, I had to rethink things a bit compared to the "classic" frontend applications with JSON API. (I have never used graphql seriously before)
-
Felix πΊπ¦π΄ββοΈreplied to Felix πΊπ¦π΄ββοΈ last edited by
-
Ben Pate π€π»replied to Felix πΊπ¦π΄ββοΈ last edited by
@leobm @cwensel Yes, this is solid advice.
The server side templates donβt need to be too sophisticated. For me, standard #golang templates have been plenty, though many gophers like the Templ library.
My routes are pretty simple. Each βobjectβ has a list of additional methods/routes that they can load, so thereβs only two levels of hierarchy and Iβve never felt like I needed more. There are a few odd widgets that I add in, but in my app theyβre usually more trouble than theyβre worth.