YouTubevideo· Oct 11, 2024· 19:47· 4,900 views on YouTube

Why Gumroad Didn't Choose HTMX

Watch on YouTube ↗
0:00

React at a moment you like. The best moments light up here.

transcript

45 moments
  1. Josh: As developers, not every tool, especially the tools that we like, we adore, we love fits for the problem at hand. I'm not oblivious to this. I wouldn't choose Livewire for every single problem that I come into contact with, but it's one of my favorite tools. And therefore I know how to solve at least most problems that I come into contact with, with Livewire. But what would be some good reasons for not choosing LiveWire and choosing something like React or Svelte or Vue with Inertia?

  2. Well, I think we can learn that by diving into this case study of why Gumroad didn't choose HTMX. This article is entitled why Gumroad didn't choose HTMX written by Sahil Lavinia. I'm probably butchering the name, but Sahil is the founder of Gumroad and a bunch of other things. You can find Sahil on XSHL. Uh, you probably have heard of that name. If not, I've heard of Gumroad, but this is Gumroad.

  3. Kind of posted and published on the HTMX articles page. And I really enjoyed it because I think it helps us think through some of these things within your own tools that you love or care for an, or adore. And so why Gumroad didn't choose HTMX. At Gumroad, we recently embarked on a new project called Helper. As the CEO, I was initially quite optimistic about using HTMX for this project, even though some team members were less enthusiastic.

  4. My optimism stemmed from previous experiences with React, which often felt like overkill for our needs. I thought HTMX could be a good solution to keep our front end super light. In fact, I shared the sentiment with our team in Slack. HTMX. org may be a way of adding simple interactions to start. And initially, it seemed promising. As one of our engineers at Gumroad eloquently put it, HTMX is officially a meme to make fun of how overly complicated the JS landscape has gotten.

  5. Much like Tailwind is just a different syntax for inline CSS, HTMX is a different syntax for inline JS. However, unlike Tailwind, which has found its place in our toolkit, HTMX didn't scale for our purposes and didn't lead to the best user experience for our customers, at least for our use case. Here's why. One intuition and developer experience, while it would have been possible to do the right thing in HTMX, we found it much more intuitive and fun to get everything working with next JS.

  6. The development process felt natural with next JS, whereas with HTMX, it often felt unnatural and forced. For example, when building complex forms with dynamic validation and conditional fields, we found ourselves writing convoluted server side logic to handle What would be straightforward client side operations and react UX limitations.

  7. HTMX ended up pushing our app towards a rail slash crud approach, which led to a really poor, or at least boring and generic user experience by default, we found ourselves constantly fighting against this tendency, which was counterproductive.

  8. For instance, implementing a drag and drop interface for our workflow builder proved to be a significant challenge, which with HTMX requiring workarounds that felt clunky compared to the smooth experience we could achieve with react libraries, AI and tooling support, it's worth noting that AI tools are intimately familiar with next JS and not so much with HTMX due to the lack of open source training data.

  9. This is similar to the issue Rails faces, while not deal breaker, it did impact our development speed and the ease of finding solutions to problems. When we encountered issues, the wealth of resources available for React and Next. js made troubleshooting much faster. Four, scalability concerns. As our project grew in complexity, we found HTMX struggling to keep up with our needs. The simplicity that initially attracted us began to feel limiting as we tried to implement more sophisticated interactions and state management.

  10. For example, as we added features like real time collaboration and complex data visualization, managing state across multiple components became increasingly difficult with HTMX is server centric approach. Five community and ecosystem. The react and next JS ecosystem is vast and mature offering solutions to almost any problem we encountered with HTMX. We often found ourselves reinventing the wheel or compromising on functionality.

  11. This became particularly evident when we needed to integrate third party services and libraries, which often had react bindings, but no HTMX equivalents. Ultimately we ended up moving to react or next JS, which has been a really great fit for building the complex UX we've been looking for. We're happy with this decision for now. It's allowed us to move faster, create more engaging user experiences and leverage a wealth of existing tools and libraries.

  12. This experience has enforced a valuable, reinforced a valuable lesson. While it's important to consider lightweight alternatives, it's equally crucial to choose technologies that can grow with your project and support your long term vision. For Helper, React and Next. js have proven to be that choice. Since we've moved there, we've been able to seriously upgrade our app's user experience for our core customers. One drag and drop functionality. Uh, one of the key features of our workflow builder is the ability to reorder steps through drag and drop while it's possible to implement drag and drop with HTMX.

  13. We found that the available solutions felt clunky and required significant custom JavaScript. In contrast, react ecosystem offers libraries like react, a beautiful D and D that provides smooth, accessible, drag, and drop with minimal setup. Two complex state management. Each workflow step has its own set of configurations and conditional logic. As users edit these, we need to update the UI in real time to reflect changes and their implications on other steps.

  14. With HTMX, this would require numerous server round trips or complex client side state management that goes against HTMX's server centric philosophy, reacts state management solutions like use state or more advanced options like Redux made this much more straightforward. Forward three dynamic form generation. The configuration for each step, uh, type is different and can change based on user input. Generating these dynamic forms and handling their state was more intuitive with reacts component model with HTMX.

  15. We found ourselves writing more complex server side logic to generate and validate these forms for real time collaboration. While not visible in the screenshot, we implemented features, allowing multiple users to edit a workflow. Workflow simultaneously implementing this with web sockets and react was relatively straightforward. Whereas with hdmx, it would have required more complex server side logic and custom JavaScript to handle real time updates.

  16. Five performance optimization as workflows grew larger and more complex. We needed. Fine grained control over rendering optimizations, reacts, virtual Dom and hooks like use memo and use callback allowed us to optimize performance in ways that weren't as readily available or intuitive with HTMX. It's important to note that while these changes aren't insurmountable with HTMX, we found that addressing them often led us away from HTMX as strengths and towards solutions that felt more natural in a JavaScript heavy environment.

  17. This realization was a key factor in our decision to switch to react and next. Yes. We acknowledge that htmx may be a great fit for many projects, especially those with simpler interaction models or those built on top of existing server rendered applications. Our experience doesn't invalidate the benefits others have found in htmx. The key is understanding your project's specific needs and choosing the tool that best aligns with those requirements. In our case, the Htmx The complex stateful nature of helpers interface made react and next JS a better fit.

  18. However, we continue to appreciate HTMX approach and may consider it for future projects where its strengths align better with our needs. I said, we're always open to reevaluating our tech stack as our needs evolve and new technologies emerge. Who knows what the future might bring. I can't speak too much on HTMX specifically while I'm familiar with what it does and the differences that it has with something like a live wire or an Alpine Ajax.

  19. Even I know the flow, I guess the DX of what you would call a server centric approach to have HTMX on the front end and then talk to a server. Everything is a round trip on the server. And then if you need any more. Um, initial client side interactions. That's when you would reach for something like a petite view or an Alpine JS, or even just something like jQuery even.

  20. And so before I dive into maybe combating or just giving some thoughts on each one of these topics that Sahil is laying out, I want to first mention this part that he said at the very end, it's, he said, We acknowledge that HTMX may be a great fit for many projects, especially those with simpler interaction models or those built on top of existing server rendered applications. Before I even go any further, I think only one of those is true in my personal experience.

  21. Simpler interaction models doesn't mean that something like HTMX or LiveWire or fill in the blank HotWire, it doesn't mean that that is invalidated. Simpler interaction models just means that you're going to have to be reaching for something in the front end more revenue, vanilla JavaScript, or jQuery or Alpine JS, when it says those built on top of existing server rendered applications, absolutely. That's why I love LiveWire.

  22. I think LiveWire is so tightly connected with Laravel and I think Hotwire, especially the newer versions of Hotwire that they kind of announced that Rails Just means that the more interconnected you are with the server, the easier some of these interactions are going to be specifically when he's talking about real time interactions or some of that state management, because you're not really doing that on the client anymore.

  23. This was something that I had to kind of wrap my head around when I moved from doing client side only JavaScript stuff, where I was having to handle state or maybe putting it in local storage or something. And now I'm like, okay. This could maybe live in cache or in the database. It doesn't necessarily have to be live in this memory state that is kind of a femoral, uh, in your application. So we go up the concerns intuition developer experience.

  24. This is kind of what, you know, is going to be a lot easier. So I believe this team and so he'll probably knows next JS more than something like HTMX. And so it's just going to be more intuitive developer developer experience is just going to be a little bit easier, even though I feel like I still, even after being a couple of years removed from the JavaScript ecosystem, the JavaScript world, I feel like I still know parts of that more than I do. PHP.

  25. I can still get an app up and running much quicker with a live wire front end with Alpine JS and Laravel back. And then I would. Doing, uh, Laravel with inertia, just because it's something that I use almost every single day. I probably build out at least a small application. And so the more intuitive you are with something, the more intuitive it's going to feel. So I don't think this is necessarily a, um, a harsh strike against HTMX UX limitations.

  26. I think that's similar to along the lines that I was talking about. It's really easy to want to, especially when you're used to the JavaScript mindset of things, if I'm just going to reach for a library, or I'm just going to reach for fill in the blank, I'm going to reach for this specific package, or I want to do everything within that tool, within HTMX, I think HTMX and things like live wire, hot wire, they usually tell you to reach outside of the tool to something like Alpine JS to something like.

  27. Um, jQuery or what have you within that specific world. I think turbo is the JavaScript approach for rails. And I think that's the same thing within HTMX. It's mostly meant for server interactions and not those UX limitations. Well, yes, a drag and drop interface that he mentioned would be extremely a little bit more.

  28. unintuitive to build and to, uh, kind of scaffold out within a HTMX or even a live wire application. There are benefits then because you are using, you have the benefit of using anything within JavaScript. I mean, there, even those D and D libraries like reacting and D for example, Yes. There might be, not be a specific, this is just a vanilla JavaScript library, but it's not that hard to bring it out from there.

  29. And if you're to be fair, if your goal is speed, then yes, there might not be a vanilla JavaScript library that works specifically for you dragging job. There probably is. Is it harder to implement than just throwing a react wrapper around it and, and putting a specific hook in here. Component. Probably. It's going to be a little harder. AI and tooling support. Um, yeah, this is fair, especially if that's something that you value.

  30. I think it's also fair to say that the more centric that you're going to be on a specific tool, the more. Also expansions, the more additional limitations that come from having that AI and tooling support, because when it comes to react and next GS, for example, next JS even has two things in their documentation, because that's really where it comes down to how many people are using it and documentation when it comes to AI and tooling support.

  31. And if there's not one clear path for something, it's much harder to then have one clear path within AI and documentation. I usually reach for something. Like a cursor or something like that. If I'm wanting to pull in the docs and it's always helpful to have kind of those up to date docs. So yeah, I think this is a valid approach. Same thing with like intuition and developer experience. Those are valid scalability concerns.

  32. And maybe there's stuff that happens within a server centric project that you immediately know that this is going to be a little bit different. Is it going to be more difficult? I don't think so. I think this is something why I love live wires, tight integration with Laravel, because then you have things like if you're doing any kind of echo servers with reverb or something like that, you just have this integration. You don't have to worry about how the inner workings happen.

  33. But that scalability usually comes with the scalability and also the, uh, maneuvering of your mindset into, yes, we would do this this way with the next JS, but it doesn't mean that we need to do that the same way within HTMX and vanilla JavaScript. And then community and ecosystem. This is something that I am very grateful for, for the layer of a world as well as like live wire world as well, just because there are so many different solutions.

  34. Not just first party and people who are, um, kind of coming up against these problems. But again, when it talks about integrating third party services, libraries, I think that's also one of the benefits of something like HTMX and a server side approach. You don't have that lock in as much.

  35. Now, this is one thing that even the LiveWire and Laravel world Uh, C's and there's folks who have like Patricia on code, who has written something like mingle JS, where you can have these react libraries, these react components into your live wire. Why? Well, because there's stuff like tremor within react, where you have this very nice, easy to use component library for React. Charts and data tables and stuff like that. And it's probably easier to pull in something like that.

  36. If you're just looking for one specific component or one specific library, I think I pretty much touched on everything there, but the dynamic form generation piece is really interesting to, again, I think a lot of this, and like I said, there are some valid concerns and just valid things that when it comes to your personal preference, uh, your. Team's preference and how you prefer to work and the things that you would prefer to use in that, that mindset that you would prefer to have as you continue to build and to grow and to scale a product.

  37. But the form piece is really interesting because I think this is another interaction that comes down to how are you used to doing something within HTMX or if you think about Livewire, you have validation on the server side. And most of the time you could still write that validation on the client side too, if you want duplicated, but it's meant for server side validation. It's just another thing that you have to think through of. This is just a different approach.

  38. I think tools like HTMX, like LiveWire and like Alpine Ajax, like others like that, allowing you and kind of force you in some way to think through. What is actually happening on the server? What do I need to happen on the client? And how should I rethink my brain to make sure that I'm doing the right thing in web standards and accessibility standards and anything else to make sure that I'm doing the right thing for my user or the right thing for my product or my tool at any given time.

  39. It's one of the reasons why, and we kind of see here at the end, uh, our experience doesn't invalidate the benefits others have found in HTMX. The key is understanding your project specific needs and choosing the tool that best aligns with those requirements. Well, I think it's also choosing the tool that best aligns with your personal preferences, your experience, and the way that you like to work. I always say that I think if someone is, knows JavaScript, And they're coming from the next JS world or the, the Svelte kit world.

  40. I wouldn't say not using inertia as might be your best bet coming into Laravel. Why? Because the developer experience of starting fresh and wanting to learn something new and be tightly integrated with the ecosystem, rather than maybe having two pieces to, to develop and to kind of take hold of, and then retrain your mindset of, okay, I'm pushing data into a platform. Frontend view. And then I'm also having to call these specific APIs or controllers.

  41. If you're used to working in that architecture, then yes, I think that would be great, but for me, I was used to working in the architecture where I just wanted to be able to see something on the server, um, grab that and have it available to me on my front end on the client, same thing with forms, just being able to call a function and say, I want this to run. And so I think it starts with shaping your mindset around, how do you like to code?

  42. It's really less about how does your application need to work? I think there's always going to be workarounds. There's always going to be trade offs. There's always going to be different libraries that you can use, pull in, copy, uh, plagiarize, do whatever you need to, along with the open source specific standards that that specific library or documentation has, but there's always going to be something that you have to give up. Or that you are like, Hey, I really like this.

  43. And for me, the benefit is being able to have that idea of this is what the server is doing. This is what the client is doing. And just like they, this Sahil and their team is probably with Next. js. You start to learn. These are the trade offs that I'm going to have to make. And I know how to have this particular problem. Once it comes up, I'm Noah, how I'm going to solve it.

  44. The more you use something, the more you build with something, the more you create with something, the better you're going to be at solving those problems. And the better you're going to be at learning how to learn how to solve those problems in the future. So whatever tech stack you choose, just make sure it's something that you're continually learning upon.

  45. You're continually building with, you're continually creating with.

just you here