Live data from Hacker News

How I use HTMX with Go

alexedwards.net

91–100 of 121 posts

Re: How I use HTMX with Go

#91
post #87

Why doesn't htmx became ultra popular among devs ?

Because it is good for a very narrow scope of things, once you go beyond that, it becomes a kludge to work with. People hate on React but it is the product of 2 decades of various experiments. It is popular because it really works.

Been building a fairly medium to large sized web app in HTMX these last few months and if done correctly, it can be done fairly cleanly and it's best combined with templates of some kind (e.g. the templating in Golang or in Django).

Re: How I use HTMX with Go

#92
For the life of me I can't comprehend how people today start new projects and default to using React. Rails Hotwire, Phoenix Liveview, HTMX are all vastly faster and easier to maintain. I keep hearing people say that if you want a really complex UI you need React but to those people I answer with 2 points.

1) Most of these people don't realize that if a component on the page is so complex you probably have usability issues.

2) React doesn't need to control the entirety of the page. You can contain your complex React components within a web page.

Re: How I use HTMX with Go

#93

HTMX is great for a lot of things, but if you're working in a team, and your colleagues are not on board, it's tough. Lots of "this is not a serious technology" kind of arguments. All kinds of bugs simply initially blamed on the choice of using HTMX. Even if proven wrong afterwards, the damage is already done. And this was in the most excellent team I have worked in so far. I'm happy that I got to experience this and…

Exactly the same thing happen to me: https://www.reddit.com/r/htmx/s/DuXyGgsCWK I'm in an advisor position, and I tried very hard to mentor the team, explaining that learning this technology deepens your understanding of the browser. Whereas React etc isolates you from the actual environment you're working in - the browser. On html/template, I like the security by default, and obviously it's built-in. But the dynamic…

I've worked with developers that don't even understand that the "form" tag exists and browser can send a request without any javascript. At some point in the early 2010's, perhaps even before, fundamental understanding disappeared. This makes it difficult to introduce alternative technologies like HTMX into a larger project.

Re: How I use HTMX with Go

#94

If you’re using htmx, I highly recommend an HTML generation technique in your backend that lets you easily componentize in the same way as you can with React. Eg, extracting common pieces of HTML markup into functions much like React components. The reason is that htmx requires a certain amount of flexibility in the HTML generated by the backend. Eg, you need to be able to generate a certain piece of HTML markup and…

You can also use jsx on the backend. React has renderToStaticMarkup, but you probably want to use one of the jsx libraries written specifically for the backend.

Re: How I use HTMX with Go

#95
post #57

Earlier quoted context omitted.

Well, the good old LAMP stack (Linux-Apache-MySQL-PHP - this was the first of these acronyms as far as I'm aware of) included L for Linux so it would make a nicer acronym. Some people changed it to WAMP when running under Windows. But HWGS doesn't roll off the tongue nicely. Maybe HAGS (with "Apple" standing in for MacOS) would work?

GASH?

SHAG!

Re: How I use HTMX with Go

#96
post #91

Earlier quoted context omitted.

Because it is good for a very narrow scope of things, once you go beyond that, it becomes a kludge to work with. People hate on React but it is the product of 2 decades of various experiments. It is popular because it really works.

Been building a fairly medium to large sized web app in HTMX these last few months and if done correctly, it can be done fairly cleanly and it's best combined with templates of some kind (e.g. the templating in Golang or in Django).

“If done correctly” applies to about everything though.

Re: How I use HTMX with Go

#97
post #92

For the life of me I can't comprehend how people today start new projects and default to using React. Rails Hotwire, Phoenix Liveview, HTMX are all vastly faster and easier to maintain. I keep hearing people say that if you want a really complex UI you need React but to those people I answer with 2 points. 1) Most of these people don't realize that if a component on the page is so complex you probably have usability…

[deleted]

Re: How I use HTMX with Go

#98

If you’re using htmx, I highly recommend an HTML generation technique in your backend that lets you easily componentize in the same way as you can with React. Eg, extracting common pieces of HTML markup into functions much like React components. The reason is that htmx requires a certain amount of flexibility in the HTML generated by the backend. Eg, you need to be able to generate a certain piece of HTML markup and…

You can also use jsx on the backend. React has renderToStaticMarkup, but you probably want to use one of the jsx libraries written specifically for the backend.

You can use JSX but tagged template literals are supported out of the box by JS runtimes, so you wouldn’t need to add a build step.

Re: How I use HTMX with Go

#99

Earlier quoted context omitted.

Ok, what’s an example of the complexity growing at 2:1 rate with htmx but not with Mantine?

Basically any data grid that implements multiple AND/OR filters at column level, sorting, reordering, infinite scrolling, virtualization for handling large amounts of data, etc. Also handling basic pending / error / retry states (things that I take for granted with React Query).

Yeah, a data grid is a good example of a complex hyper-interactive component. There are people out there who have made them with Web Components, which can be dropped in and used in htmx projects when used correctly.

Re: request states, handled very nicely out of the box by htmx with a little knowledge of attributes like hx-indicator and JS event handlers to handle htmx error events.

Re: How I use HTMX with Go

#100
post #15

Go + Datastar is simpler, I much prefer it.

Yeah this combo fits as easily as a custom sized/fitted gloves would. I would add a-h/templ for templates and it has Datastar support as well. It is staggering how Datastar is not more popular.

I think people see the "pricing" and are turned off. The base is completely free! Some of the ecosystem is not. The big selling point for me, is the size of the library. HTMX and Alpine are a bit larger. The downside for me is needing to have a template type that supports streaming. (Thymeleaf in Java vs JTE) My controllers also have imperative code to support the streaming. None of this is enough of a turnoff however. For my simple apps, I'm extremely happy with how simple both HTMX and Datastar make my logic. (I replaced a React front-end and got rid of the whole build step).
Post reply on HN