Who's using HTMX with Clojure and how's it going?

As someone who started web dev in about 2005, it is definitely a blast from the past. It reminds me very much of the Dojo toolkit. But to be honest, we were pretty damned productive with Dojo - that was IMHO a totally underrated approach. I’m curious to hear how many folks are using it (or something similar) with Clojure. And how it’s going, how you are doing it, would you do it again. I’m considering using a hybrid approach where only certain parts of the app need to be re-frame.

5 Likes

I just started using it during the holidays and it’s been a blast. I re-wrote the frontend of a personal webapp[1] from re-frame (via Luminus) into an hiccup/ctmx based one (via kit-clj + ctmx). Half the lines of code, way fewer deps, no npm, codebase overall makes more sense to me. Was even able to fix a few annoyances that I had left dangling over the course of 2022. Honestly I had to spend more time learning about integrant than about htmx/ctmx.

[1] I may or may not release it on Github one of these days…

Now I’m planning on using what I learned to rewrite a side-project as well, before it gets too unwieldy.

Both of these are quite compatible with the HTMX approach. Dynamic web UIs but mostly CRUD, not so much machine-to-machine requirement but human interaction as the main interface, so they lend themselves well to this.

1 Like

good to know, thanks. I’m currently leaning towards kit too, so was checking out ctmx.

I would recommend going for it and trying it out!

Took me a bit of time to figure out integrant, but it was good experience doing so, since not everything came pre-configured out of the box (e.g. getting the database query-fn to be available in routes, and the db connection itself so I could use next.jdbc/with-transaction, had to learn how to wire all that up – and I’m coming out better as a result of finally understanding this).

then I paired that with the recently-released (but incomplete) online, free, ebook from the makers of HTMX at https://hypermedia.systems to have a good understand how to structure my app, and lots of trial and error to figure out routes, components, etc with kit-clj, ring, integrant and ctmx (it does work slightly different from what I was used to with the way Luminus sets it up), but it all works in the end.

1 Like

I’m experimenting with it. Our SPA has grown pretty large and the build process takes around 3 minutes. Years ago I read one of Paul Graham’s essays, where he describes how they build their company viaweb back in 1995. It was one of the first web applications and they build it with LISP. It was a huge competitive advantage to beat average competitors. Most of them build native applications which had release cycles of several months. While viaweb could fix bugs on the same day.

One story reasonated with me a lot, where Paul Graham described how they had telephone calls with their customers to handle support cases. They connected to the server via the REPL and fixed the bug while the customer was still on the telephone. For a lot of customers this looked like magic.

Meanwhile 28 years I’m building a SaaS with a Lisp, but my build process takes over 5 minutes. I also connect via the REPL to our production servers to understand and diagnose bugs. But I’m far away from this power Paul Graham already had 1995. Mainly since my SPA takes at least 3 minutes to build.

Why I’m telling you all this. I hope projects like HTMX can bring me nearer to this dream to instantly update my production web application.

2 Likes

htmx is fantastic. It really reduces the complexity of modern web apps, and I love it for that. It’s one of those things that’s obvious in hindsight.

A minimalistic yet full stack (incl. database and prod deployment) Clojure framework that leans on htmx is Biff. Check it out; it’s pretty neat.

2 Likes

I played with HTMX + Babashka GitHub - prestancedesign/babashka-htmx-todoapp: Quick example of a todo list SPA using Babashka and htmx and it was very interesting.
I would surely use this stack for a future project.

2 Likes

Hi ,

Andrei implemented the htmx examples </> htmx - Examples in clojure as a reference, using kit-clj if you want to check them out: GitHub - sandre1/clj-training: A place where we can all learn a bit of clojure. .

The code is almost complete, some minor tweeks required.
I hope you find it usefull.

Eugen

2 Likes