Skip to content

v1.6.0 — htmx SPA integration

Choose a tag to compare

@acoshift acoshift released this 19 Jul 13:44
· 4 commits to master since this release
efadca2

Server-rendered apps that feel like a SPA with htmx — one template set, no client build step. See the htmx guide.

Fragment rendering

  • ctx.View("page#form", data) renders a single {{block}}/{{define}} of a view through the same minify/ETag pipeline as full pages.
  • ctx.ViewPartial(name, fragment, data) — fragment for htmx partial requests, full page for everyone else (deep links, back button, JS-off).
  • Breaking (parse time only): # is now reserved — registering a template or component name containing it panics at parse time.

htmx helpers

  • Predicates ctx.IsBoosted() and ctx.WantsPartial() (pure header reads; IsHTMX() unchanged).
  • app.HTMXAwareRedirect (opt-in): the whole Redirect family answers partial htmx requests with HX-Redirect + 204 instead of a 3xx, so post/redirect/get + flash flows work unchanged over htmx.
  • New chainable helpers: HTMXPushURL, HTMXReplaceURL, HTMXNoPush, HTMXReselect, HTMXLocation, HTMXTriggerAfterSwap, HTMXTriggerAfterSettle.
  • Behavior change: repeated HTMXTrigger calls now merge into one header instead of clobbering (merged events serialize in alphabetical order).

Caching

  • ctx.NoCache() — chainable Cache-Control: no-store.
  • ctx.VaryHTMX() — chainable Vary: HX-Request, HX-Boosted, HX-History-Restore-Request for cacheable responses that branch on htmx headers. Nothing sets Vary automatically; call it when you need it.

Docs

  • README htmx section: partial rendering, out-of-band swap pattern, active-nav recipe, 422 validation config, caching guidance.
  • Modernized CSRF guidance: explicit SameSite cookies + Go 1.25's http.NewCrossOriginProtection instead of token middleware (#124).

Full changelog: v1.5.0...v1.6.0 (#123, #124)