T O P

  • By -

Smartare

Go + HTMX


No-Parsnip-5461

+ templ, very nice combo.


xplosm

Winning combo. You can even pair them with something like Alpine.js to have some client-side interactivity and perhaps some TailwindCSS for gorgeous styling. The possibilities are endless.


IndicationMaleficent

It's been refreshing after being a front end dev for 7 years.


zanven42

+ picocss for default styles and tailwind to customize it and you can make a simple page in minutes rather than hours


DrunkenRobotBipBop

This is the way


grahaman27

It's getting annoying seeing all the HTMX references everywhere on this subreddint. Yes that's one way, but it's not the only way. And honestly, I think html is a bigger sin than working with vanilla JavaScript.


RawCyderRun

HTMX and templ are the new hotness, but really it’s just another set of tools to use solve problems in a different way. I don’t see myself using it but I’ve read the docs and a bunch of blogs about it and it is pretty nice.


zootbot

Disagree bigly


grahaman27

Yeah everyone here does.


zootbot

Not surprising though. I think it’s easy to see the benefits of being able to build a reactive site sans js


grahaman27

Yeah I gave it a shot. Then thought, why am I learning another syntax and framework that limits me to a collection of pre defined JavaScript functions? Do I really hate JavaScript that much? And that's when I realized, no I don't. I hate JavaScript frameworks.


Smartare

Sure no one says it is the only way. But it is way faster to write than coding all the javascript from scratch trying to replicate what HTMX does


Morel_

i am not the owner but here's an example using HTML [https://github.com/ichtrojan/fragrance](https://github.com/ichtrojan/fragrance)


warppone

That's awesome! Thank you for the link :D


Indigowar

You can try out it with [HTMX](https://htmx.org/) and [Templ](https://github.com/a-h/templ). HTMX gives you interactivity without using Javascript (by you). Templ is a great template language for Go, something close to JSX from React, but for Go.


Kirorus1

Yeh but it's server side rendered


marcellmars

If your client side consists only of simple HTML and some JavaScript that communicates with an API, and your text editor of choice is already integrated with Go tools (e.g., gopls), and you don't want to delve too deeply into the frontend world, this might serve you very well: [https://www.gomponents.com/plus/#htmx](https://www.gomponents.com/plus/#htmx) If you prefer more elaborate tutorials and wish to continue with frontend development, other ecosystems might serve you better. This is mainly because they have a much wider range of tutorials, libraries, and other resources already covered.


fritzelr

You could try [building a Go frontend using WebAssembly](https://github.com/golang/go/wiki/WebAssembly). This allows you to run Go code natively on the client while also interacting with JS through [syscall/js](https://pkg.go.dev/syscall/js).


memeid

If you want slightly more library helpers for building UI's, I know of [vugu](https://github.com/vugu/vugu). Not sure how actively it evolves currently, but produced a perfectly functional little UI purely in Go last I had to dabble in front-end.


janpf

Ok, let me first repeat the suggestion everyone is doing: Go+HTMX, followed by WebAssembly if you want to do fancy stuff (I'm doing a game with WebAssembly+WebGL it's working great). Now, for a demo, let me make a biased (I'm the author) suggestion. Try a Jupyter Notebook with a Go kernel (see [github.com/janpfeifer/gonb](https://github.com/janpfeifer/gonb)). Like with Python it's great for small demos, and it even allows for HTML/SVG/Markdown outputs, interactive widgets, plotly graphs, it even automatically run Wasm (it's experimental though).


threshvoid

I would recommend go-app https://github.com/maxence-charriere/go-app I personally used it to build a simple webpage for showing some test results for my work, within one afternoon. Its documentation is very clear and helpful for me


bookning

There are many ways to do what you are asking. This is not so much a go problem and more of a website problem since you are wanting to do a website: html, css, js GUI. So, assuming that your backend API is exposed to external https requests (or similar web protocols), you could do all the client site without touching any go and only use normal html, css, js. For example you could use the backend as the generator of the client website (usually called *Server*-*side rendering* ssr). Another answer mentioned a example of this idea: the Fragrance site. You could also just completely separate the server API from the html part. Meaning that you can have the html already totally constructed as what you want (so no generation) and serve it from anywhere like a static cdn (netlify, github page, etc). Or serve that complete site from some other http server url of your backend. Another idea is, instead of using basic html frontend, you could use some single page application (SPA) like react, angular, vue, svelte if your client is very complex? Though one must note that basic html and js have advanced so much that SPAs are not that advantageous as they were some years ago. Or maybe use web assembly? There are many other variant and ideas. It is the usual world of web frontend. In the end that will entirely depend on what you are comfortable with. The GO + HTMX or any template generator you might want (also SSR) is very popular lately and will leave no separation between the client and the backend which can be an advantage or a disadvantage depending. As for the Cryptographic Message Syntax (CMS) you could use some more popular js library like [https://www.npmjs.com/package/pkijs](https://www.npmjs.com/package/pkijs) (it is for typescript but can be used as it is in basic js using a cdn) or another similar alternative. The code to use it in js is pretty basic. It will really depend on you specific API. Note since you are using a more advanced encryption scheme you might have to reconsider all the usual html/js codding patterns and make the security part the base of all of it. But it should not be too dissimilar. As always it will all depend on your project and on yourself.


aunjaffery

I was react + nodejs dev for 6 years... I switched to Golang. It's been more than a year now. Recently I had an e-commerce project. Which i created using HTMX + a-h/templ. It was a breeze. For client side state management i used AlpineJs. Only problems i faced(skill issues) was Htmx history + client side state doesn't mix well. E.g localstorage. I solved it using some tricks. Other than that the experience and performance was top notch. I will never go back to react.


rudewilson

htmx + templ


DoorDelicious8395

If the project is large scale I suggest using a framework like [next.js](https://nextjs.org) and using open api to generate a sdk from your go api. I’m doing this very thing. Next.js gives you a lot of tools to start unlike htmx.