frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

HTMX is hard, so let's get it right

https://github.com/BookOfCooks/blog/blob/master/htmx-is-hard-so-lets-get-it-right.md
34•thunderbong•2h ago

Comments

alex-moon•2h ago
These kinds of write-ups are so key to driving adoption of a new technology. I'm still not super interested in HTMX but this write-up has done a lot of the work already toward nudging me that way. Well done!
rapnie•31m ago
Yes, as I remember it it was a 'back to simplicity' of the early web idea. Rediscover the power of hypermedia. I don't know HTMX well, but am following Datastar [0] which was inspired by it, and their selling points are Simplicity and Performance and take it some steps further than HTMX. The approach does shift logic / complexity towards the backend though.

[0] https://data-star.dev

totaa•1h ago
congrats on the first blog post, been using Go+Templ+HTMX when implementing my first startup

I think at least some of these issues can be avoided with a different UI/UX to avoid passing temporal/unsaved data between screens.

looking forward to the next instalment!

throw310822•45m ago
I read through this and I don't get it. Recreating an entire form on the backend and swapping it with the current one, and then missing the update of the label status?

Then solving this by recreating the entire stepper html at each step, with the added complexity that if it contains something you want to keep "it's a nightmare"?

Then having to create a temporary server-side session to store data that somehow the browser can't keep between two clicks?

Etc.. it's write web apps like it's 1999.

junon•40m ago
Also the title itself does a disservice to HTMX; wasn't it billed as sort of "modern frameworks are bloated and difficult, let's go back to Simple"?
fvdessen•21m ago
HTMX is indeed simple and lean, but unfortunately that doesn't mean solving common frontend problems with HTMX is simple either. After a decade of frontend dev and being tired of react/vue/etc, I tried HTMX, wanting for something leaner, but IMHO it has big problems, and I am back to react/vue.

The two biggest problems with HTMX is that being fully server side controlled you need to put the whole app state in the URL and that quickly becomes a nightmare.

The other is that the code of components is split in two, the part that is rendered on the first time, and the endpoint that returns the updated result. You need a lot of discipline to prevent it from turning that into a mess.

The final nail on the coffin for me was that the thing I wanted to avoid by picking HTMX; making a rest api to separate the frontend and the backend, was actually a good thing to have. After a while I was missing the clean and unbreakable separation of the back and front. Making the rest api was very quickly done, and the frontend was quicker to write as a result. So HTMX ended up slower than react / vue. Nowadays react/vue provide server side rendering as well so i'm not sure what Htmx has to bring.

Polarity•38m ago
> I originally planned to make a simple non-functional uploader, then progressively bring it from "it works™" to "high-quality production-grade Uploader with S3 Presigned, Multipart, Accelerated Uploads, along with Auto-Saving and Non-Linear Navigation

Why is every developer trying to make things complicated?

andrewstuart•36m ago
All that seems rather ….. indirect. Every step of the way I kept urging him to use JavaScript.
lmz•8m ago
They could have done all that in one long form with JS for client side progressive enhancement (show/ hide different parts) and that would probably be much easier.
kissgyorgy•34m ago
This implementation is unnecessary complicated. For the step update, you can use Out Of Band update: https://htmx.org/attributes/hx-swap-oob/ which works in a way that you can send multiple HTML fragments which can be anywhere on the page and HTML swaps them out. Good for notifications, step update, breadcrumb update, menu highlight, etc...

I usually solve the second problem by simply saving the state of the individual input fields, you only need a user session. Depending your use-case, you might need to be transactional, but you can still do this saving everything as "partial" and close the "transaction" (whatever it might mean in the given context) at the last step. Much-much simpler than sending form data over and over.

devnull3•31m ago
This should be trivial with the HTMX alternative: datastar [1]

In datastar the "Out Of Band" updates is a first class notion.

[1] https://data-star.dev

meander_water•16m ago
HTMX has out of band updates too [0], what's the differentiator?

[0] https://htmx.org/attributes/hx-swap-oob/

devnull3•11m ago
In DS, with SSE you can paint different parts of the page with ease. So in this case, it can update <form> and <label> separately. So instead of one update the backend fires 2. There is not separate marker or indicator for OOB.

I think it is best seen in examples on DS website.

karel-3d•25m ago
Every time I attempt to use HTMX and backend-rendered templates because it's "simpler", in the end I always end up doing JSON APIs and something like Svelte. Because all the "simplicity" explodes in complexity 5 seconds later, and it's very user-hostile with the constant reloads.

This blogpost affirms it

devnull3•22m ago
> Challenge 2: Passing data down each step

Why not use cookies?

hackrmn•19m ago
Related: https://htmx.org/essays/htmx-sucks/ (on the actual HTMX upstream site)
rtpg•15m ago
that form state persistence looks soooo gnarly. Really have a hard time arguing that's better than a client side header
brokegrammer•9m ago
I built my latest SaaS (https://clarohq.com) using HTMX, backed by Django. I really enjoy the process because HTMX allows reactivity using swaps and plain Javascript events instead of server side state management, useeffect, and API endpoints.

However, it's difficult to get things right. I spent way too much time on some basic features that I could have shipped quicker if I used React.

The issue with React though, is that you end up with a ton of dependencies, which makes your app harder to maintain in the long-term. For example, I have to use a third-party library called react-hook-form to build forms, when I can do the same thing using plain HTML and a few AlpineJS directives if I need dynamic fields.

I'm not sure if I'll ever build an app using HTMX again but we need more people to write about it so that we can nail down patterns for quickly building server rendered reactive UIs.

bookofcooks•4m ago
Hey, author here! Ask me anything!

I want to make the intent of this blog post extremely clear (which tragically got lost when I got deep into the writing).

I love HTMX, and I've built entire sites around it. But all over the internet, I've seen HTMX praised as this pristine perfect one-stop-solution that makes all problems simple & easy (or at least... easier than any framework could ever do).

This is a sentiment I have not found to be true in my work, and even one where the author of HTMX spoke out against (although I can't find the link :(

It's not a bad solution (it's actually a very good solution), but in real production sites, you will find yourself scratching your head sometimes. For most applications, I believe it will make ALMOST everything simpler (and lighter) than traditional SPA frameworks.

But for some "parts" of it, it is a little tricker, do read "When Should You Use Hypermedia?" [1];

In the next blog post (where we'll be implementing the "REAL" killer features), I hope to demonstrate that "yes, HTMX can do this, but it's not all sunshine & rainbows."

---

On a completely separate note, one may ask, then, "why use HTMX?" Personally, for me, it's not even about the features of HTMX. It's actually all about rendering HTML in the backend with something like Templ [2] (or any type-safe html templating language).

With Templ (or any type-safe templating language), I get to render UI from the server in a type-safe language (Golang) accessing properties that I KNOW exist in my data model. As in, the application literally won't compile & run if I reference a property in the UI that doesn't exist or is of the incorrect type.

You don't get that with a middle-man API communication layer maintained between frontend and backend.

All I need now is reactivity, and htmx was the answer. Hope you understand!

[1] https://htmx.org/essays/when-to-use-hypermedia/#if-your-ui-h...

[2] https://templ.guide/

KDE Plasma prepares crackdown on focus-stealing window behavior under Wayland

https://www.neowin.net/news/kde-plasma-prepares-crackdown-on-focus-stealing-window-behavior-under-wayland/
1•bundie•47s ago•0 comments

Photonic SNN chip reaches 1 GHz and supports on-chip learning

https://arxiv.org/abs/2506.14272
1•juanviera23•2m ago•0 comments

So Long to Tech's Dream Job

https://www.nytimes.com/2025/08/04/technology/tech-jobs-silicon-valley-changes.html
1•gist•3m ago•0 comments

Dark clouds ahead: hyperscalers can't safeguard one nation's data from another

https://www.theregister.com/2025/08/04/when_hyperscalers_cant_safeguard_one/
1•rntn•9m ago•0 comments

Pianobook gets new creative director

https://www.youtube.com/watch?v=fH9VQbzc0-g
1•tomcam•13m ago•0 comments

A.I. Has Ushered in Silicon Valley's 'Hard Tech' Era

https://www.nytimes.com/2025/08/04/technology/ai-silicon-valley-hard-tech.html
1•ianrahman•14m ago•0 comments

The Q Programming Language

https://git.urbach.dev/cli/q
1•ygritte•16m ago•0 comments

Libra AI: The open-source V0/Lovable alternative

https://github.com/nextify-limited/libra
1•yaobingxun•17m ago•0 comments

Practical Steps to Avoid ChatGPT Psychosis

https://carsonogenic.substack.com/p/practical-steps-to-avoid-chatgpt
1•thatsso1999•19m ago•1 comments

Britain missed the first crypto wave. We can't miss the second

https://www.ft.com/content/3eded430-a854-44d6-9739-e8a350eae25f
1•NomDePlum•24m ago•1 comments

Fun with MeshBlend

https://www.c0de517e.com/024_meshblend.htm
1•ibobev•24m ago•0 comments

The curse of 'Disco Elysium', the greatest RPG ever made

https://www.ft.com/content/5ae5bf4f-4c05-4286-8133-5b812309d636
1•tolien•25m ago•1 comments

Debugging AMD-Specific Issues with Driver Experiments Tool

https://asawicki.info/news_1788_debugging_amd-specific_issues_with_driver_experiments_tool
1•ibobev•25m ago•0 comments

OpenAI Needs Adult Supervision

https://www.thepourquoipas.com/post/openai-needs-adult-supervision
1•ThePourquoiPas•27m ago•0 comments

Perfecting anti-aliasing on signed distance functions

https://blog.pkh.me/p/44-perfecting-anti-aliasing-on-signed-distance-functions.html
3•ibobev•27m ago•0 comments

Pocket ID: A Simple but Powerful OIDC Provider for SSO with Passkeys

https://github.com/pocket-id/pocket-id
1•alexanderameye•34m ago•0 comments

Show HN: I Built a Web App with Svelte and GPTs

https://www.ivontime.com/app
1•liviu31•37m ago•0 comments

Open Music Foundation Models for Full-Song Generation

https://map-yue.github.io/
1•selvan•37m ago•0 comments

Plastics a 'grave' danger to health, scientists warn before UN talks

https://www.ft.com/content/09108445-c1cb-45c2-b145-d767d56aeb7b
3•cebert•37m ago•1 comments

Tesla Approves Interim 96M Stock Award for Musk

https://www.bloomberg.com/news/articles/2025-08-04/tesla-approves-interim-stock-award-for-musk-ahead-of-pay-vote
2•helsinkiandrew•38m ago•1 comments

Ask HN: UX – What time consuming tasks have you successfully automated?

1•iolmao•39m ago•0 comments

Show HN: PageZero – Learn any skill through AI-driven interactive prompts

https://pagezero.ai
1•hskhawaja•39m ago•0 comments

Show HN: AI Sandbox with Kata, Firecracker, Cloud HV (E2B, Daytona Alternative)

https://www.cognitora.dev
2•mikerubini•40m ago•1 comments

Steve Wozniak is not boring

https://github.com/moby/moby/blob/master/pkg/namesgenerator/names-generator.go
2•TheSilva•44m ago•2 comments

Show HN: Pro quality AI themed photo packs from your selfies curated by humans

https://coolphoto.ai
4•ferreirarmp•45m ago•0 comments

Phaistos Disc

https://en.wikipedia.org/wiki/Phaistos_Disc
2•wjSgoWPm5bWAhXB•47m ago•0 comments

Tesla board awards $29B of shares to Elon Musk

https://www.ft.com/content/ae085ae9-3d15-4d68-a28f-39c88e8bf8c8
4•TheAlchemist•50m ago•1 comments

Show HN: I connected mediapipe Hand Landmarker with SplashCursor

https://trizuliak.com/experiments/magic-finger
2•trizoza•54m ago•0 comments

Millions of age checks performed as UK Online Safey Act gets rolling

https://www.theregister.com/2025/08/04/millions_of_age_checks_performed/
1•jjgreen•57m ago•0 comments

Show HN: I built DeepTap – a simple deep link management tool

https://deeptap.io
1•road42runner•1h ago•0 comments