Skip to content
Skills Library
Programming · Building & coding

htmx

/htmx

htmx for Go/templ apps: hx-* attributes, swap strategies, triggers, OOB updates, SSE, WebSockets, forms, redirects, debounce, server integration. Trigger when user writes or pastes templates containing hx-* attributes, asks about HTMX swaps/triggers/OOB updates, or wires HTMX to a Go handler. SKIP generic web, fetch/AJAX, or templUI questions with no htmx context.

Repository
gopher-ai ↗
Licence
MIT
Last repository change
20.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
5
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 20.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

htmx for Go/templ apps: hx-* attributes, swap strategies, triggers, OOB updates, SSE, WebSockets, forms, redirects, debounce, server integration. Trigger when user writes or pastes templates containing hx-* attributes, asks about HTMX swaps/triggers/OOB updates, or wires HTMX to a Go handler. SKIP generic web, fetch/AJAX, or templUI questions with no htmx context.

Original author description

htmx for Go/templ apps: hx-* attributes, swap strategies, triggers, OOB updates, SSE, WebSockets, forms, redirects, debounce, server integration. Trigger when user writes or pastes templates containing hx-* attributes, asks about HTMX swaps/triggers/OOB updates, or wires HTMX to a Go handler. SKIP generic web, fetch/AJAX, or templUI questions with no htmx context.

How it works

  1. Core Principles
  2. Reference Files
Original SKILL.md headings · 60 lines, 408 words
SKILL.md preview
---
name: htmx
description: "htmx for Go/templ apps: hx-* attributes, swap strategies, triggers, OOB updates, SSE, WebSockets, forms, redirects, debounce, server integration. Trigger when user writes or pastes templates containing hx-* attributes, asks about HTMX swaps/triggers/OOB updates, or wires HTMX to a Go handler. SKIP generic web, fetch/AJAX, or templUI questions with no htmx context."
---

# htmx Best Practices & Go/Templ Integration

Apply correct htmx patterns when building hypermedia-driven web applications, especially with Go and templ.

## Core Principles

- **Return HTML fragments, not JSON** — htmx is designed for hypermedia; the server returns rendered HTML
- **Use HTML attributes, not JavaScript** — prefer `hx-*` attributes over `htmx.ajax()` or `fetch()` calls
- **Server controls behavior** — use response headers (`HX-Retarget`, `HX-Reswap`, `HX-Redirect`) for control flow
- **Check `HX-Request` header** — return fragments for htmx requests, full pages for normal requests
- **Don't mix paradigms** — avoid using `fetch()` alongside htmx in the same page; pick one approach

---

## Reference Files

Read the relevant file for detailed patterns, code examples, and best practices:

### `templ-integration.md` — Templ + htmx
- CRITICAL: Templ interpolation rules (dynamic attributes, `{ }` vs quoted strings)
- Dynamic JSON in `hx-vals` — use `json.Marshal`, not `fmt.Sprintf`
- URL construction patterns (fmt.Sprintf, concatenation, templ.URL)
- Templ component patterns (spread attributes, conditional attributes, full page vs partial)
- JavaScript and `hx-on` events in templ (JSFuncCall, OnceHandle, event name syntax)
- Embedding Go data in script tags
- Alpine.js listening to htmx events from templ

### `go-handlers.md` — Go Server Patterns
- Fragment vs full page response (`isHTMXRequest` helper)
- Separate routes for partials vs full pages
- Multi-target OOB responses (writing multiple components)
- htmx-aware redirects (`HX-Redirect` instead of HTTP 302)
- Event-driven list reloads with `HX-Trigger` header
- Delete with empty response
- Validation error re-rendering with error state

### `attributes-reference.md` — Swap, Triggers & Headers
- Swap strategies table (innerHTML, outerHTML, delete, morph, etc.) and modifiers
- Trigger patterns (events, special triggers, modifiers, filters, multiple triggers)
- Self-terminating polling pattern
- Request headers (sent automatically) and response headers (server control)
- Out-of-Band (OOB) swap patterns and gotchas

### `patterns-and-extensions.md` — Advanced Patterns
- Error handling (4xx/5xx don't swap by default — 4 solutions)
- Filter state preservation with `hx-include` and `hx-push-url`
- Forms and file uploads (auto-submit, progress, external values, radio/checkbox)
- Inline editing pattern (read-only row ↔ edit form)
- Alpine.js + htmx integration (separation of concerns, event listening, `htmx.process()`)
- Loading indicators and disabled elements
- Sync strategies (`hx-sync`: replace, abort, queue)
- Target selectors (this, closest, next, previous, find)
- Extensions (json-enc, SSE, WebSockets, head-support, preload)
- JavaScript event patterns (delegation, afterSwap vs afterSettle, `htmx.onLoad`)
- Common anti-patterns table
- CSRF protection pattern
- Configuration via meta tag
- Useful Go libraries (htmx-go, go-htmx, typed-htmx-go)
Files in this package (5)
  • SKILL.md 3 KB
  • attributes-reference.md 5 KB
  • go-handlers.md 3 KB
  • patterns-and-extensions.md 14 KB
  • templ-integration.md 9 KB

Versions

RepositoryScoreLicence
This page · gopherguides/gopher-ai100MIT
ericrisco/rsc-harness100MIT
j4flmao/agent-skills100MIT
G1Joshi/Agent-Skills100MIT
piyiotisk/htmx-skills100MIT

Database snapshot: 13.11.2026 · package version 14ddae50ca3d (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100templ-htmx
    Build interactive hypermedia-driven applications with templ and HTMX. Use when creating dynamic UIs, real-time updates, AJAX interactions, mentions 'HTMX', 'dynamic content', or 'interactive templ app'.
  • 95templ-htmx
    Build interactive hypermedia-driven applications with templ and HTMX. Use when creating dynamic UIs, real-time updates, AJAX interactions, mentions 'HTMX', 'dynamic content', or 'interactive templ app'.
  • 95goldr-app
    Create, bootstrap, edit, debug, review, or extend applications that use the Goldr Go web framework. Use when Codex needs to add Goldr to an app, work on Goldr routes, layouts, pages, fragments, actions, templ templates, trusted first-party HTML or Markdown content pages, HTMX…
  • 86add-page
    Add a server-rendered page, or a form that posts with htmx and swaps a partial, to this Go templ app, with its route, view types, error handling and tests. Use when the user asks for a new page, screen, form, partial, fragment or htmx interaction.
  • 100htmx-progressive-enhancement
    Use when building server-driven UIs with htmx, designing hx-* attribute compositions, choosing swap strategies (innerHTML/outerHTML/morph), wiring out-of-band updates, integrating with form validation, or migrating from a SPA back to server-rendered HTML. Triggers:…
  • 100templui
    Version-aware templUI v1 and shadcn-templ v2 component guidance for Go/templ apps. Use for component installation, UI blocks, Script() setup, HTML-to-templ conversion, or Go-to-JavaScript interpolation. Offers an upgrade when legacy templUI is encountered. Skips generic HTMX…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.