Agent Skill
2/7/2026

htmx-alpine

Use when building server-driven web applications with HTMX and Alpine.js - covers the interaction model, when to use each tool, and when NOT to use raw JavaScript

N
neoeinstein
0GitHub Stars
1Views
npx skills add neoeinstein/claude-plugins

SKILL.md

Namehtmx-alpine
DescriptionUse when building server-driven web applications with HTMX and Alpine.js - covers the interaction model, when to use each tool, and when NOT to use raw JavaScript

name: htmx-alpine description: Use when building server-driven web applications with HTMX and Alpine.js - covers the interaction model, when to use each tool, and when NOT to use raw JavaScript

HTMX + Alpine.js Patterns

Overview

Build server-driven web applications where the server returns HTML and the client manages UI state. HTMX handles all server communication. Alpine.js handles client-side state that doesn't need server round-trips.

Core principle: The server is the source of truth. The client is a thin rendering layer.

Quick Reference - What to Load

If you're...Load
Using hx-get, hx-post, hx-target, hx-swapreferences/htmx-requests.md
Managing UI state with x-data, x-modelreferences/alpine-state.md
Coordinating HTMX and Alpine togetherreferences/integration.md
Building a reusable confirm dialog for destructive actionsreferences/integration.md
Adding loading spinners, error handlingreferences/feedback-patterns.md
Using SSE or WebSocket extensionsreferences/realtime.md
Concerned about focus, ARIA, screen readersreferences/accessibility.md
Using Axum + Askama for handlersreferences/frameworks/rust-axum.md

When to Use Each

NeedUseNot
Submit form to serverHTMX hx-postJavaScript fetch()
Update page sectionHTMX hx-target + hx-swapJavaScript DOM manipulation
Show/hide elementAlpine x-showJavaScript classList toggle
Track form stateAlpine x-data + x-modelJavaScript variables
Loading indicatorHTMX hx-indicator or Alpine :disabledJavaScript event handlers
Multi-step flowAlpine state + HTMX requestsJavaScript state machine
Real-time updatesHTMX SSE/WS extensionJavaScript WebSocket API

Core Principles

Server is Source of Truth: Business logic and data validation belong on the server. The client is a rendering layer that displays HTML from the server and provides immediate UI feedback.

HTMX for Server Roundtrips: Use hx-* attributes for any operation that needs server data: form submissions, partial page updates, search results, inline validation. The server returns HTML fragments, not JSON.

Alpine for Client-Only State: Use x-* attributes for UI state that never needs to persist: dropdown visibility, modal open/closed, form field focus, character counts. If the user refreshes and the state is gone, that's fine.

Progressive Enhancement: The page should be usable without JavaScript. HTMX and Alpine enhance the experience but aren't required for basic functionality.

Accessibility is Not Optional: Dynamic content requires focus management, ARIA live regions, and keyboard navigation. See references/accessibility.md.

STOP — Anti-Rationalization Table

Before writing code that matches these patterns, STOP and reconsider.

You're about to...Common rationalizationWhat to do instead
Use fetch() for a form submission"I know fetch, HTMX is new" / "More control"Use hx-post. HTMX handles all the edge cases you'll forget. Load references/htmx-requests.md.
Store server data in Alpine x-data"It's faster than round-tripping" / "Just caching"Keep server data on the server. Alpine state should be UI-only. Load references/alpine-state.md.
Skip focus management after swap"Users can click" / "PM says ship it"Users include keyboard and screen reader users. Load references/accessibility.md.
Build a wizard with Alpine-only state"Steps are just UI"Multi-step flows need server persistence. Use HTMX for each step, Alpine for in-step UI.
Ignore loading indicators"It's fast enough"It's not always fast. Add hx-indicator. Load references/feedback-patterns.md.
Use innerHTML in JavaScript"Just this once"Use HTMX hx-swap. If you need it, Alpine x-html (with caution).
Send JSON over WebSocket and build DOM client-side"It's more flexible" / "We need structured data"Server renders HTML fragments. Send them directly via htmx-ws with OOB swaps. Load references/realtime.md.

Common Mistakes

MistakeFix
Using fetch() for form submissionsUse HTMX hx-post
JavaScript DOM manipulation for updatesUse HTMX hx-swap
JavaScript variables for UI stateUse Alpine x-data
Missing x-cloak on Alpine elementsAdd [x-cloak] { display: none !important; }
No ARIA live region for dynamic contentAdd aria-live="polite" to update containers
Modal without focus trapImplement focus trapping or use library

Authoritative Resources

Skills Info
Original Name:htmx-alpineAuthor:neoeinstein