| How I use HTMX with Go(alexedwards.net) | |
| 273 points by gnabgib 16 hours ago | 77 comments | |
tl;dr: A walkthrough of building Go web apps with HTMX, focusing on a template rendering pattern using a shared `htmlRenderer` type that can serve either full pages or partials from the same template files, with assets embedded via `go:embed`. Key techniques include checking the `HX-Request` header to conditionally return partials vs. full pages (with a `Vary: HX-Request` response header), handling redirects via `HX-Redirect`, and configuring HTMX to swap error responses into `<body>`, disable history caching, and turn off attribute inheritance. | |
HN Discussion:
| |