Fork me on GitHub
Richard Bowen06:08:09

htmx and hyperscript look interesting. Does it provide SPA like functionality without being an SPA? How simple is it to swap out htmx/hyperscript for ClojureScript and re-frame? I saw in one of your videos you were using ClojureScript @foo.

Jacob O'Bryant06:08:47

Yeah, previous to January, Biff used cljs by default. > Does it provide SPA like functionality without being an SPA? Yep, pretty much. It's especially good for crud-type things. I also sometimes use drop-in JS components too, like a rich text editor, or multiselect component, etc. Then you can get some interactivity while still keeping all your application state in the DOM and coding it like a plain server-rendered app. As for switching to cljs and reframe--it shouldn't be any harder than adding them to a regular server-rendered app. Which is to say, it would take a bit of work to set it up since Biff no longer provides any cljs stuff out of the box, but the default htmx/hyperscript setup won't make that process any more difficult than it otherwise would've been. Hope that makes sense 🙂.

Jacob O'Bryant06:08:18

I might be interested to write a how-to guide for adding in cljs to a biff project, but it isn't too high priority--for the time being I'd rather try to see how far htmx can go. though if someone else were to write it I'd definitely link to it from the docs.

Richard Bowen15:08:21

Cool. How do you handle reusable components using htmx?

Jacob O'Bryant18:08:09

Usually they're just functions that return hiccup (rum actually, to be specific). e.g. this That file has a number of other components as well. I actually use htmx somewhat sparingly; I default to regular multi-page apps with form posts and redirects and such, and then only add in some htmx in cases when that's too limiting. I just mention this since I don't specifically have an example of a reusable component that uses htmx. But if I did it would be in the same style as the ones in that file. maybe have the component take an htmx rest endpoint as a parameter. For JS components, see,, and an example of using a rich-text editor (tiny mce).

👍 1
Richard Bowen18:08:38

Ah, so you use htmx with hiccup, interesting.

Jacob O'Bryant18:08:56

Yeah. htmx doesn't do any rendering on its own. So it's not really a 1:1 replacement for e.g. React. It's more like... an extension for what you can do with HTTP, which allows you to write more interactive apps with whatever tools you were already using for server-side rendering/request handling.

Jacob O'Bryant18:08:53

(or to be more precise, it's an extension for the browser that allows it to use http in more ways)

👍 1

HTMX and hyperscript are pretty capable, Here's a couple of examples of how they're being used in place of traditional SPA's.

🔥 1
Richard Bowen00:09:26

Server-side routing?


Yep, Java and Go respectively. Check out the HTMX showcase channel on discord; plenty of other examples there:

👍 1