DEV Community

Cover image for HTMX is fine until the third stakeholder wants a modal
Aditya Agarwal
Aditya Agarwal

Posted on

HTMX is fine until the third stakeholder wants a modal

HTMX was successfully implemented in a production environment earlier this year. Then, out of the blue, the third stakeholder expressed their desire for a modal. They tend to break your lovely little world of HTMX snappy actions that got a free pony, a grenade, and a lollipop.

That's usually when the fantasy cracks. ๐Ÿซ 

The pitch is real, and it works

HTMX made a surprising return that no one in the SPA community had expected. Fast forward to 2026, and it is being used to run real production dashboards, as opposed to just small demos.

And to be honest? It works really well for dashboards.

HTML is sent over the network. The server does the rendering, the fragment is replaced, and you can leave work before schedule.

There's no need for hydration. There's no need for a client-side state to get out of sync with the server. There's no need for 200KB of JavaScript to render a table of numbers.

This is the right tool for read-heavy screens with the occasional filter. I would not hesitate to use it.

Then reality shows up in a suit

It's not HTMX that's the problem. It's what comes next once the prototype is successful.

Stakeholder one is really happy with the dashboard. Stakeholder three has requested a modal that can edit a row without having to leave the page.

Sure. Enter hx-get into a conversation, replace it, close it if successful. Also clean.

So, stakeholder one needs to be able to save wherever they are when they navigate away, stakeholder two wants one specific row of their entire overview to be constantly updating, and stakeholder three wants a counter on their "new" draft, as well as the entire row behind it, to be updating while also not losing the draft when they navigate away.

You are now managing state in three different locations via HTTP. Congratulations on reaching the cliff!

This is the moment when those who claim "scales to anything" stop arguing.

None of this is hard to do. It's just not easy anymore.

"PHP spaghetti" is a lazy insult that's half right

Critics often refer to HTMX as a regression back to PHP spaghetti.

When your interactivity grows, your logic spreads across components, endpoint handlers, and a bunch of hx- attributes.

Your UI is not stored in one location for you to read. It is indicated by which fragment was last replaced.

That's the actual cost. Not the tech, the legibility.

A React component is messy but the state at least exists in a place you can reference and discuss.

Highly responsive HTMX applications frequently involve lots of state changes on the server and a lot of template updates across multiple browser windows post-POST. It's an illusion that what you have locally is the "current" UI.

The honest version of the pitch

We have implemented it before, and we would do it again if it's a suitable choice for a specific interface.

What really bothers me is the lack of honesty. Saying "HTMX scales to anything" is marketing language, not technical language.

The truth is boring and useful:

โ†’ Server-rendered simplicity is a genuine win until interactivity crosses a line
โ†’ That line is real, it exists, and pretending otherwise burns junior devs who trust the hype
โ†’ The cliff usually shows up around state split across multiple locations and client-held state
โ†’ Picking HTMX means deciding in advance how spicy your UI is allowed to get

The most successful HTMX applications I've encountered are not those that resisted the cliff. They are the ones which have drawn a solid line and declared "beyond this point, we are fine with some JavaScript."

A little bit of Alpine. A small island of actual client state. Not a renunciation of the belief, but maturity. ๐Ÿ™‚

The takeaway

HTMX is a fantastic tool with a specific shape. It rewards apps that are mostly server-truth with light interaction, and it punishes apps that pretend they're that when they're not.

The complexity cliff is not a bug in HTMX. It's a bug in how people sell it.

So, let me ask you this: Where do you have the most difficulty with HTMX? Was it the modal? The multi-window update? Or was it when a PM looked you in the eye and said, "Can it be Notion-like?"

Top comments (1)

Collapse
 
yawaramin profile image
Yawar Amin

Just fyi we donโ€™t any htmx for a modal. We donโ€™t even need JavaScript. See developer.mozilla.org/en-US/docs/W...