4 ms·
Ask HN: Are You Using Htmx?
https://htmx.org
"htmx gives you access to AJAX, CSS Transitions, WebSockets and Server Sent Events directly in HTML, using attributes, so you can build modern user interfaces with the simplicity and power of hypertext."
I'd like to hear experiences folks have had with using HTMX. I see a lot of great comments about it online. Is there anything holding it back from larger adoption?
- PaulHoule 4y agoI am using it. It is good for dropdowns that immediately send a state change to the server as soon as you change them. It is also good for a classification process where you might make several judgements about a document in a structured way and the back end can replace the judgement buttons with different buttons depending on what you chose the first time, then finally reload the whole thing and move to the next document.
- leephillips 4y agoIt’s great. If you have a static site with no javascript and you want to add some interactivity or replace some reloads with some ajax interactions, html makes it easy to sprinkle this in without having to rewrite the whole thing. It’s very small and efficient, and easy to work with. > Is there anything holding it back from larger adoption? I don’t know or care. If I were the only one in the world using it, it would make no difference. It’s self-contained and trivial to self host.
- PaulHoule 4y agoOne thing that "holds it back" is that it doesn't have a general theory of the whole page. A really complex application may have many parts of the UI that are influenced by a piece of data changing. Some examples would be a knowledge graph editor, CAD program, Adobe Photoshop, IDE, etc. There could be a static list of components involved, known at the design time, say a main editor pane and a sidebar and a status bar. In the most complex case, however, the UI could be dynamic and the user could create property sheets and other UI elements that could have an arbitrary number of UI elements that are affected by a data change. It's very possible to write something like that in React although it isn't easy. HTMX doesn't have a theory for the "application" as a whole, rather it is about being able to redraw different parts of the interface, it is probably not that hard to trigger a status bar to redraw in the same event that triggers a div to get redrawed but in general it seems an HTMX application has to be built around what is easy in HTMX.
- leephillips 4y agoYes, no doubt there are many applications for which htmx (or any other tool you can name) are not ideal. For me, I’ve found it useful and easy to add ajax-type progressive enhancements to old-fashioned Django sites, for example. And they work just as before for users without javascript.
- PaulHoule 4y agoThat's what I am doing. I find the "standard model" of writing your application twice these days (write a back end and write a front end) is highly expensive particularly for applications that require agility. I worked at a place where we built a system people would complete tasks (like AMZN's Mechanical Turk) to train machine learning models and it should be quick to just push a new task out to people by writing a new a file, but with the single-page-application you need to not just write the back end but also recompile the front end and force people to reload it. Contrast that to an "old-school" application where you put up a new file and your new task is online. I found HTMX is great for my own model trainer/workflow system. I still can't understand why all the web design shops in my town that were doing great with Ruby on Rails felt compelled to do everything in Angular (which they struggled at) and then ditched angular for React (which they've stuck with.)
- mejutoco 4y agoYou can update several elements of a page in htmx with a single request. Otherwise it would be a deal breaker. I am on the phone but I think this is the attribute https://htmx.org/attributes/hx-swap-oob/ https://htmx.org/attributes/hx-swap-oob/ With it you return several ids and the right elements update. I do exactly that on one of my websites https://fromzerotofullstack.com/ https://fromzerotofullstack.com/
- yawaramin 4y agoIt doesn't have a general theory of the whole page because it's not meant to take over the whole page and turn it into an app. That's what SPA frameworks are for. Htmx is for sprinkling interactions on top of existing server-rendered pages and it works really well for that.
- recursivedoubts 4y ago> Is there anything holding it back from larger adoption? I'm the creator of htmx. A few things: * it isn't from and supported by a big tech company like google or facebook * it is idiosyncratic, using hypermedia rather than the more popular RPC/reactive approach of most front end libraries * there are very few job postings mentioning it, and most folks, for obvious and valid reasons, want to learn libraries that are relevant for jobs I'm very happy w/ how much traction it's gotten though, and I expect it will keep growing in the future. I doubt it will ever be anywhere near the big front end libraries, but if it's a small, stable tool that makes things better for some people, that's good enough for me.
- leephillips 4y agoThis attitude is another reason I like htmx. It’s happy to do what it does, and do it extremely well, without trying to encompass the entire universe.
- vyrotek 4y agoThis is why I love HN. :) Thank you for your efforts! I just recently discovered it. It looks like a breath of fresh air for those of us who have been doing this stuff for a long time. As you said, discoverability is probably the only reason why it's not more well known. There are devs who haven't ventured out of React for their entire careers and don't know to look for better tools for different problems.
- leros 4y agoDoes HTMX have a niche where would you suggest a company use it over the more popular libraries?
- recursivedoubts 4y agoi think if you have a dev team that wants to do full stack developement and who has a preference for a non-JS backend, it can be a good fit. You should consider if the app you are building is amenable to the hypermedia approach htmx takes though: https://htmx.org/essays/when-to-use-hypermedia/ https://htmx.org/essays/when-to-use-hypermedia/ The django community has picked it up and had some good success w/ it: https://htmx.org/essays/a-real-world-react-to-htmx-port/ https://htmx.org/essays/a-real-world-react-to-htmx-port/
- leros 4y agoI only know of one company using HTMX and they're currently rewriting their apps in React. Solo projects are obviously one thing, but in a company you want to use popular technology to make hiring easier.
- lucapanof 4y agoI used to write most of my front-end applications in clojurescript with reagent + reframe. I really love the reframe way to write react components and for this very reason I really never considered other alternatives until I discovered htmx. Working with htmx in clojure is really fun. In reagent I used to write hiccup, handlers and state code. Now I just write hiccup and instead of writing handlers and state code I rely on the htmx attributes and hyperscript when necessary - maybe beacause of backend constraints or else. Finally, I extended hyperscript conversion to let it parse js hiccup. That really made my day. It's really powerful. Overall, only positive feedbacks from my relatively small experience.
- vyrotek 4y agoHere are some interviews with the creator, Carson Gross. https://www.dotnetrocks.com/details/1749 https://www.dotnetrocks.com/details/1749 https://changelog.com/gotime/266 https://changelog.com/gotime/266
- mejutoco 4y agoI do use it with django. I make sure to create a data structure with all the htmx ids to ma sure I can find all the places that update an element. Otherwise it gets messy.
- leke 4y agoI've used it for the first time in an application with a lot of dynamic form situations. I generally update the "main" tag which appears to speed up the performance.
- yawaramin 4y agoI'm using it for a personal project and for a couple of different company-internal projects at work. My personal project is making more complex use of it, with different (server-rendered) components. Like with anything else, you need to keep a handle on complexity with many different components rendering different parts of the page. On the whole though it works really well. The internal apps at work are benefitting from it because I get exactly the interactions I need (confirmation of some action, async requests submission and page update) with extremely minimal footprint, just a small snippet of custom JS and CSS.