htmx
HTMX development guidelines for building dynamic web applications with minimal JavaScript using HTML attributes.
What this skill does
# HTMX Development
You are an expert in HTMX for building dynamic web applications with minimal JavaScript.
## Core Principles
- Write concise, clear, and technical responses with precise HTMX examples
- Leverage HTMX's interactivity capabilities without heavy JavaScript dependencies
- Prioritize maintainability and readable code structure
- Return only necessary HTML snippets from the server
## HTMX Usage Guidelines
### Request Attributes
- `hx-get` - Make GET request to URL
- `hx-post` - Make POST request to URL
- `hx-put` - Make PUT request to URL
- `hx-patch` - Make PATCH request to URL
- `hx-delete` - Make DELETE request to URL
### DOM Manipulation
- `hx-target` - Specify where response content gets injected
- `hx-swap` - Customize DOM insertion method (innerHTML, outerHTML, beforeend, etc.)
- `hx-trigger` - Customize event handling and control request timing
- `hx-select` - Select specific content from response
### URL Management
- `hx-push-url` - Update browser URL without full page refresh
- `hx-replace-url` - Replace current URL in history
## Best Practices
### Request Handling
```html
<!-- Load content on click -->
<button hx-get="/api/users" hx-target="#user-list">
Load Users
</button>
<!-- Submit form via AJAX -->
<form hx-post="/api/submit" hx-target="#result" hx-swap="innerHTML">
<input name="email" type="email">
<button type="submit">Submit</button>
</form>
```
### Error Handling
- Implement server-side validation before processing requests
- Return appropriate HTTP status codes (4xx for client errors, 5xx for server errors)
- Provide user-friendly error messages
- Use `hx-swap` for customizing error feedback presentation
### User Confirmation
```html
<button hx-delete="/api/item/1"
hx-confirm="Are you sure you want to delete this?">
Delete
</button>
```
## Performance Optimization
- Minimize server response sizes by sending only essential HTML
- Implement server-side caching for frequently requested endpoints
- Precompile reusable component fragments
- Use `hx-boost` for progressive enhancement of links
## Integration Patterns
### With CSS Frameworks
- Combine HTMX with Bootstrap or Tailwind without script conflicts
- Use loading indicators for better UX
- Handle transitions smoothly
### Template Organization
- Organize templates as efficient, reusable HTMX fragments
- Maintain clear separation of concerns
- Use partial templates for common components
## Key Conventions
- Maintain consistent naming for HTMX attributes
- Ensure fast and intuitive interactions
- Structure templates with clear separation of concerns
- Favor declarative attributes over JavaScript event handlers
Related in Web Dev
generating-lwc-components
IncludedLightning Web Components with PICKLES methodology and 165-point scoring. Use this skill when the user creates or edits LWC components, builds wire service patterns, or writes Jest tests for LWC. TRIGGER when: user creates/edits LWC components, touches lwc/**/*.js, .html, .css, .js-meta.xml files, or asks about wire service, SLDS, or Jest LWC tests. DO NOT TRIGGER when: Apex classes (use generating-apex), Aura components, or Visualforce.
tanstack-query
IncludedManage server state in React with TanStack Query v5. Set up queries with useQuery, mutations with useMutation, configure QueryClient caching strategies, implement optimistic updates, and handle infinite scroll with useInfiniteQuery. Use when: setting up data fetching in React projects, migrating from v4 to v5, or fixing object syntax required errors, query callbacks removed issues, cacheTime renamed to gcTime, isPending vs isLoading confusion, keepPreviousData removed problems.
document-processor-api
IncludedProcess documents with Nutrient DWS. Use when the user wants to generate PDFs from HTML or URLs, convert Office/images/PDFs, assemble or split packets, OCR scans, extract text/tables/key-value pairs, redact PII, watermark, sign, fill forms, optimize PDFs, or produce compliance outputs like PDF/A or PDF/UA. Triggers include convert to PDF, merge these PDFs, OCR this scan, extract tables, redact PII, sign this PDF, make this PDF/A, or linearize for web delivery.
nutrient-document-processing
IncludedProcess documents with Nutrient DWS. Use when the user wants to generate PDFs from HTML or URLs, convert Office/images/PDFs, assemble or split packets, OCR scans, extract text/tables/key-value pairs, redact PII, watermark, sign, fill forms, optimize PDFs, or produce compliance outputs like PDF/A or PDF/UA. Triggers include convert to PDF, merge these PDFs, OCR this scan, extract tables, redact PII, sign this PDF, make this PDF/A, or linearize for web delivery.
tanstack-query
IncludedManage server state in React with TanStack Query v5. Covers useMutationState, simplified optimistic updates, throwOnError, network mode (offline/PWA), and infiniteQueryOptions. Use when setting up data fetching, fixing v4→v5 migration errors (object syntax, gcTime, isPending, keepPreviousData), or debugging SSR/hydration issues with streaming server components.
accelint-nextjs-best-practices
IncludedNext.js performance optimization and best practices. Use when writing Next.js code (App Router or Pages Router); implementing Server Components, Server Actions, or API routes; optimizing RSC serialization, data fetching, or server-side rendering; reviewing Next.js code for performance issues; fixing authentication in Server Actions; or implementing Suspense boundaries, parallel data fetching, or request deduplication.