Go + HTMX: Hypermedia Apps
A sequel to Shipping Go, for the other full-stack shape: server-rendered apps where handlers return HTML over the wire — the simplest full-stack Go there is. htmx turns any element into an HTTP client, your handlers respond with html/template fragments instead of JSON, and SQLite in WAL mode sits underneath. No API layer, no client framework, no frontend build step — one Go binary serving a working app. You'll wire the hypermedia loop, structure templates that render both full pages and fragments, handle form validation round trips with inline errors, tune the SQLite DSN for concurrent handlers, and finish with an honest guide to when this model wins and when a React SPA is the better call.
5 lessons · ~2 hours
1. HTML Over the Wire
Hypermedia, not JSON
htmx turns any element into an HTTP client, and your Go handlers answer with HTML fragments — no JSON layer, no client-side rendering, the server is the app.
Templates that scale
html/template parses once at startup via embed.FS and template.Must, named partials render both the full page and the htmx fragment, and auto-escaping makes hostile input inert.
Forms and validation
The POST round trip has two outcomes — success swaps in the new row, failure re-renders the form fragment with inline errors and a 422 — and htmx 2 needs one config line to swap 422 bodies at all.
SQLite under a hypermedia app
The WAL + busy_timeout + foreign_keys DSN keeps SQLite's single writer from surfacing as "database is locked", and list/row query patterns pair one query with one partial.
Choosing HTMX
Hypermedia wins where state lives on the server — CRUD, admin, forms; a React SPA wins on rich client state, realtime, and offline — and either way the app ships as one binary with htmx vendored in.