Skip to content
Back to skills

Htmx Pages

ASecurity

Build server-driven UI with htmx safely: fragments, swap targets, CSRF headers, OOB updates and errors

  • 5 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 30, 2026
developmentapifrontendbackendsecurity

Works with

  • cli
  • api

Security analysis

A100/100

Scanned November 30, 2026

npx -y skills add AdityaaaTiwari/ANVIL --skill htmx-pages --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Htmx Pages?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Htmx Pages
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/adityaaatiwari-htmx-pages/badge)](https://www.skillsdirectory.com/skills/adityaaatiwari-htmx-pages)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
description: Build server-driven UI with htmx safely: fragments, swap targets, CSRF headers, OOB updates and errors
profile: standard
tags: htmx, html, frontend, backend
---

# htmx pages

Use when adding `hx-*` attributes, partial HTML endpoints, or out-of-band swaps to server-rendered pages.

## Fragments and swap hygiene
- Return semantic HTML fragments (not full `<html>` documents) for partial `hx-get` / `hx-post` requests unless `hx-boost` explicitly swaps `body` or `hx-select` scopes it. Check the `HX-Request` header when serving shared URLs.
- Always specify explicit `hx-target` and `hx-swap` (`innerHTML`, `outerHTML`, `beforeend`) so layout surprises do not wipe sibling controls.
- Use `hx-swap-oob="true"` sparingly with unique element IDs when updating secondary badges or counters alongside the primary target.

## Security and UX
- Configure CSRF protection cleanly once via `<body hx-headers='{"X-CSRF-Token": "..."}'>` or `htmx:configRequest` event listener instead of repeating hidden inputs on non-form triggers.
- Escape every dynamic user value in HTML templates; htmx inserts server responses straight into the DOM.
- Disable repeated clicks on mutations with `hx-disabled-elt="this"`, add `hx-indicator`, and return explicit HTTP `4xx` / `5xx` error fragments handled intentionally (`response-targets` or `htmx:responseError`).

## Verify
Tests checking both full-page `GET` and `HX-Request: true` partial responses, CSRF enforcement on mutations, XSS escaping in returned fragments, and history navigation (`hx-push-url`).

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.