Avatar

Francisco Moschetti

Uruguay.
Web developer alergic to leetcode.

Back to blog

HTMX pilled

So I decided to give HTMX a try in the least suited project for such thing: a websockets heavy app.

The core pieces of soundbits.live rely on HTMX - Handling a new websocket message and showing it in the livestream is all handled by the websockets plugin provided by HTMX. Of course Iā€™m also using it to make the UI experience feel better, even though this product doesnā€™t need to support a lot of user interactions in the admin.

The modules for SSE and websockets make HTMX a great tool to use in AI apps (stream chat respones), or just any async and reactive stuff really.

I kinda wanted to put it to the test and see in wich scenarios HTMX makes the most sense over a JS metaframework. After seeing how easy and familiar it was, I became an extremist (jk but not so much).

The realization

This sounds weird, but Iā€™m really starting to believe there is only 2 ways of doing things:

  • Server driven applications (BE framework + HTMX)
  • Local first (Your favorite JS framework + indexed DB + some sort of sync)

Iā€™m a BE dev, and the recent explosion of meta frameworks (NextJS, Sveltekit) sounded like the ideal scenario for me to start learning more about FE.

The problem is that the ā€˜magicā€™ of these frameworks abstract you from the standards you learn while doing BE, and it takes a lot of time to fully understand and use these frameworks well.

Not saying I donā€™t like them, I love Svelte. But is hard to ignore the anxiety I get when iā€™m debating using one of these tools for a internal tool or any production project, not because of the ā€œscalabilityā€ issues or whatever, but the fact that I know I will end up wasting 3 hours debuging an issue caused by a single line of code that changes how the framework renders a page or something very nuanced to the way the tool operates.

Currently building a local first app with svelte and itā€™s been an amazing experience, it kinda depends on what you are building, how do you plan on monetize, and a lot of different factors, but i can say with enough confidence that 90% of the B2B SaaS ideas you can think of shouldnā€™t even consider anything over HTMX and a robust BE framework.

You can always ā€œsprinkleā€ client side interactions with something like Alpine or petite-vue if you really need to in the worst cases.