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.