Show HN: Build progressively enhanced reactive HTML apps using Go and Alpine.js
127 points| realrocker | 2 years ago |livefir.fly.dev
The Fir toolkit is designed for Go developers with moderate html/css & js skills who want to progressively build reactive web apps without mastering complex web frameworks. It includes a Go library and an Alpine.js plugin.
How it works ?
On receiving user-interactions the fir server re-renders html templates and sends it over the wire where the fir client library selectively updates the changed areas.
When a user event is received by a Fir route, an array of html templates are rendered on the server and returned as an array of DOM events to the browser. The DOM events are consumed by the alpinejs plugin and dispatched within the DOM where listeners attached to elements can use the event to update the DOM.
See the demo and quickstart here: https://livefir.fly.dev/
ajd1988|2 years ago
How does Fir handle more complex scenarios such as nested components, handling form submissions with client-side validation, and integrating third-party APIs or libraries?
Does the toolkit offer any built-in functionality or guidelines for handling these cases, or is the developer expected to handle them using custom code and Alpine.js plugins?
Also the site is super slow!
realrocker|2 years ago
[edit] This is still a work-in-progress so I will certainly add better guides and documentation moving forward. Although its good to get feedback that this approach might be interesting for at least some people.
fshr|2 years ago
realrocker|2 years ago
kindofabigdeal|2 years ago
lormayna|2 years ago
This is a very simple and clean Go templating library.
jakelazaroff|2 years ago
There are plenty of valid criticisms of React/etc, but the one thing they got really really right was making "templates" be normal functions that return a data structure representing the HTML. Logic is way less awkward, no global variables spanning partials in different files and it's impossible to write incorrectly nested markup. I really wish backend-only frameworks would steal that idea.
whiddershins|2 years ago
Or is it because I first clicked the full reload example several times?
iOS
realrocker|2 years ago
quickthrower2|2 years ago
Anyway I am lazy, so I would probably just use HTMX boosting:
realrocker|2 years ago
htmx is great!
mcspiff|2 years ago
examplary_cable|2 years ago
[1] ilse.ink/components(It's not ready yet)
TigerTeamX|2 years ago
ilse.ink/components didn't work. Could you post a link to it?
msolberg|2 years ago
I ended up packaging my frontend in an nginx container and using that same nginx container as a proxy for the backend but the whole time I thought maybe this small project would be easier if everything was served by go.
Will definitely keep an eye on this for future stuff.
cyneox|2 years ago
But I think for future projects I might use HTMX + Tailwind.
[1]: https://gocial.netlify.app/
[2]: https://github.com/dorneanu/gocial
Art9681|2 years ago
realrocker|2 years ago
drusepth|2 years ago
cloudking|2 years ago
realrocker|2 years ago
husarcik|2 years ago
hyeomans|2 years ago
realrocker|2 years ago
mtlynch|2 years ago
earthboundkid|2 years ago
RamblingCTO|2 years ago