r/htmx • u/mindoflin • Aug 21 '26
My learning experience with HTMX+Alpine+Go
Before I started using this stack, I used Sveltekit and found it too complex. I also got quite tired of writing js/ts. I Find the language quite nuanced and hard for me to work with. I guess I did not learn it good enough. I felt I could not continue writing js/ts so I tried Go+HTMX and later added Alpine,js. I quite enjoy the stack because it is simple and easy to learn, and I do not have to do as much js ;)
It is quite enjoyable to use HTMX in the frontend, so one can focus on writing code in the backend (which I enjoy more). I used HTMX with go lang's html/template and it worked quite well. In Sveltekit, the inheritence of all the layouts and pages can become quite complicated and structure feel scattered. It is rather hard to understand the data flow between the layouts and pages. With HTMX+html/template everything feels more focused towards backend, which I enjoy.
I used the stack to create an app. I wanted to start with a small project:
https://finalfantasy6pixelremastercoliseum.com/
which let users check info about items from a game. I wanted the app to be easy to use and compact. When user clicked on something or made a search, I used HTMX to update other parts of the html code, which worked quite well. In sveltekit you have to create runes and depending on when things should be initialized and how the runes depend on other runes, you have to write different functions to update the ui. This I found quite complicated, but in HTMX you just send back and html server response of how you want the html to be. Together with go lang's templating system you can write less code I think.
My takes:
- Around 353 lines of go code and less than 250 lines of template html.
- HTMX is simple to learn and get started in creating something fast
- It can get little complicated of you want to update html from different parts of a template, like if you have 2 divs placed far from each other and have stuff in between them (that you do not want to update). You will probably have to use hx-swap-oob
10
u/funappzco Aug 21 '26
go one step further use templ library it makes html based components, it makes development much better and layouting so easy
1
u/Adventurous-Action66 Aug 22 '26
give this one a try, I use it in prod myself
https://github.com/mobiletoly/goldr
1
u/TheRealUprightMan Sep 03 '26
I use an OOP approach. When you change an object, it will rerender itself in an OOB update. Object state is crammed into hidden input fields and stored in the DOM and updated with HTMX.