Debian Codegraph @

www/src/content/essays/why-gumroad-didnt-choose-htmx.md

raw
1 ---
2 title: "Why Gumroad Didn't Choose htmx"
3 description: "In this essay, Sahil Lavingia, CEO of Gumroad, explains why the company decided against using htmx for its new project, Helper, in favor of React and Next.js. He shares the challenges faced with htmx, including issues with developer experience, user experience limitations, scalability, and AI tool support. While acknowledging htmx's potential for simpler projects, Lavingia emphasizes how React and Next.js offered better solutions for complex features like real-time collaboration, drag-and-drop functionality, and dynamic forms. Ultimately, Lavingia highlights the importance of selecting technologies that can grow with the project's needs."
4 created: 2024-09-30
5 modified: 2024-09-30
6 authors: ["Sahil Lavingia"]
7 tags: ["counterpoints"]
8 ---
9
10 At Gumroad, we recently embarked on a new project called [Helper](https://helper.ai). As the CEO, I was initially quite
11 optimistic about using [htmx](https://htmx.org) for this project, even though some team members were less enthusiastic.
12
13 My optimism stemmed from previous experiences with React, which often felt like overkill for our needs. I thought htmx
14 could be a good solution to keep our front-end super light.
15
16 <figure>
17 <a href="/img/gumroad-red.jpeg" target="_blank">
18 <img alt="GitHub screenshot shows deleted files" src="/img/gumroad-red.jpeg" style="width: 100%">
19 </a>
20 <figcaption>Source with htmx - Click Image To View</figcaption>
21 </figure>
22
23 In fact, I shared this sentiment with our team in Slack:
24
25 > "https://htmx.org/ may be a way of adding simple interactions to start"
26
27 And initially, it seemed promising! As one of our engineers at Gumroad eloquently put it:
28
29 > "HTMX is (officially) a meme to make fun of how overly complicated the JS landscape has gotten - much like tailwind is
30 > just a different syntax for inline CSS, HTMX is a different syntax for inline JS."
31
32 However, unlike Tailwind, which has found its place in our toolkit, htmx didn't scale for our purposes and didn't lead
33 to the best user experience for our customers–at least for our use case.
34
35 Here's why:
36
37 1. **Intuition and Developer Experience**: While it would have been possible to do the right thing in htmx, we found it
38 much more intuitive and fun to get everything working with Next.js. The development process felt natural with
39 Next.js, whereas with htmx, it often felt unnatural and forced. For example, when building complex forms with dynamic
40 validation and conditional fields, we found ourselves writing convoluted server-side logic to handle what would be
41 straightforward client-side operations in React.
42
43 2. **UX Limitations**: htmx ended up pushing our app towards a Rails/CRUD approach, which led to a really poor (or at
44 least, boring and generic) user experience by default. We found ourselves constantly fighting against this tendency,
45 which was counterproductive. For instance, implementing a drag-and-drop interface for our workflow builder proved to
46 be a significant challenge with htmx, requiring workarounds that felt clunky compared to the smooth experience we
47 could achieve with React libraries.
48
49 3. **AI and Tooling Support**: It's worth noting that AI tools are intimately familiar with Next.js and not so much with
50 htmx, due to the lack of open-source training data. This is similar to the issue Rails faces. While not a
51 dealbreaker, it did impact our development speed and the ease of finding solutions to problems. When we encountered
52 issues, the wealth of resources available for React/Next.js made troubleshooting much faster.
53
54 4. **Scalability Concerns**: As our project grew in complexity, we found htmx struggling to keep up with our needs. The
55 simplicity that initially attracted us began to feel limiting as we tried to implement more sophisticated
56 interactions and state management. For example, as we added features like real-time collaboration and complex data
57 visualization, managing state across multiple components became increasingly difficult with htmx's server-centric
58 approach.
59
60 5. **Community and Ecosystem**: The React/Next.js ecosystem is vast and mature, offering solutions to almost any problem
61 we encountered. With htmx, we often found ourselves reinventing the wheel or compromising on functionality. This
62 became particularly evident when we needed to integrate third-party services and libraries, which often had React
63 bindings but no htmx equivalents.
64
65 <figure>
66 <a href="/img/gumroad-green.jpeg" target="_blank">
67 <img alt="GitHub: 1 added file" src="/img/gumroad-green.jpeg" style="width: 100%">
68 </a>
69 <figcaption>Source with Next.js - Click Image To View</figcaption>
70 </figure>
71
72 Ultimately, we ended up moving to React/Next.js, which has been a really great fit for building the complex UX we've
73 been looking for. We're happy with this decision–for now. It's allowed us to move faster, create more engaging user
74 experiences, and leverage a wealth of existing tools and libraries.
75
76 <figure>
77 <a href="/img/gumroad-helper-before-after.png" target="_blank">
78 <img alt="The old Gumroad Helper interface is quite basic with a single flat form,
79 while the new one has multiple levels of navigation and editable lists."
80 src="/img/gumroad-helper-before-after.png" style="width: 100%">
81 </a>
82 <figcaption>Gumroad Helper Before & After - Click Image To View</figcaption>
83 </figure>
84
85
86 This experience has reinforced a valuable lesson: while it's important to consider lightweight alternatives, it's
87 equally crucial to choose technologies that can grow with your project and support your long-term vision. For Helper,
88 React and Next.js have proven to be that choice.
89
90 Since we've moved there, we've been able to seriously upgrade our app's user experience for our core customers.
91
92 1. **Drag-and-Drop Functionality**: One of the key features of our workflow builder is the ability to reorder steps
93 through drag-and-drop. While it's possible to implement drag-and-drop with htmx, we found that the available
94 solutions felt clunky and required significant custom JavaScript. In contrast, React ecosystem offers libraries like
95 react-beautiful-dnd that provide smooth, accessible drag-and-drop with minimal setup.
96
97 2. **Complex State Management**: Each workflow step has its own set of configurations and conditional logic. As users
98 edit these, we need to update the UI in real-time to reflect changes and their implications on other steps. With
99 htmx, this would require numerous server roundtrips or complex client-side state management that goes against htmx's
100 server-centric philosophy. React's state management solutions (like useState or more advanced options like Redux)
101 made this much more straightforward.
102
103 3. **Dynamic Form Generation**: The configuration for each step type is different and can change based on user input.
104 Generating these dynamic forms and handling their state was more intuitive with React's component model. With htmx,
105 we found ourselves writing more complex server-side logic to generate and validate these forms.
106
107 4. **Real-time Collaboration**: While not visible in this screenshot, we implemented features allowing multiple users to
108 edit a workflow simultaneously. Implementing this with WebSockets and React was relatively straightforward, whereas
109 with htmx, it would have required more complex server-side logic and custom JavaScript to handle real-time updates.
110
111 5. **Performance Optimization**: As workflows grew larger and more complex, we needed fine-grained control over
112 rendering optimizations. React's virtual DOM and hooks like useMemo and useCallback allowed us to optimize
113 performance in ways that weren't as readily available or intuitive with htmx.
114
115 It's important to note that while these challenges aren't insurmountable with htmx, we found that addressing them often
116 led us away from htmx's strengths and towards solutions that felt more natural in a JavaScript-heavy environment. This
117 realization was a key factor in our decision to switch to React and Next.js.
118
119 We acknowledge that htmx may be a great fit for many projects, especially those with simpler interaction models or those
120 built on top of existing server-rendered applications. Our experience doesn't invalidate the benefits others have found
121 in htmx. The key is understanding your project's specific needs and choosing the tool that best aligns with those
122 requirements.
123
124 In our case, the complex, stateful nature of Helper's interface made React and Next.js a better fit. However, we
125 continue to appreciate htmx's approach and may consider it for future projects where its strengths align better with our
126 needs.
127
128 That said, we're always open to reevaluating our tech stack as our needs evolve and new technologies emerge. Who knows
129 what the future might bring?