litestar-htmx

Detect HTMX requests and return server-rendered HTML fragments in Litestar.

7|1|Updated Mar 2, 2026
One-click install
npx skills add https://github.com/alti3/litestar-skills --skill litestar-htmx
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: litestar-htmx
Source: https://github.com/alti3/litestar-skills/tree/main/plugins/litestar/skills/litestar-htmx
Command: npx skills add https://github.com/alti3/litestar-skills --skill litestar-htmx

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Build HTMX-driven Litestar endpoints to serve server-rendered HTML fragments for partial updates and progressive enhancement. Do not use for SPA-only JSON APIs that do not exchange HTML fragments.

Core Features & Use Cases

  • Detect HTMX requests via the HX-Request header and return fragment payloads.
  • Coordinate with litestar-templating and litestar-responses to drive client behavior.
  • Use cases include server-rendered components, partial page updates, and dynamic in-place content.

Quick Start

Create an HTMX-enabled Litestar route that returns a minimal HTML fragment when the HX-Request header is present.

Frequently Asked Questions about litestar-htmx

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I return server-rendered HTML fragments from Litestar endpoints for HTMX requests?

To return server-rendered HTML fragments, Litestar endpoints check the HX-Request header and return fragment payloads for partial updates. This preserves full-page behavior for non-HTMX requests while enabling progressive enhancement.

What is progressive enhancement in Litestar using HTMX partial updates?

Progressive enhancement using HTMX partial updates means Litestar endpoints serve full-page responses normally but return server-rendered HTML fragments when the HX-Request header is present, enabling dynamic in-place content updates without a SPA.

Can I use HTMX with Litestar for partial page updates without building a SPA?

Yes, you can use HTMX with Litestar for partial page updates without a SPA by returning server-rendered HTML fragments. Endpoints detect the HX-Request header to deliver fragment substitutions for dynamic in-place content.

How do I set up an HTMX-enabled Litestar route that serves fragment templates?

To set up an HTMX-enabled Litestar route, apply fragment-focused templates that return a minimal HTML fragment when the HX-Request header is present. This coordinates with litestar-templating and litestar-responses to drive client behavior.

When should I not use HTMX fragment endpoints in Litestar?

You should not use HTMX fragment endpoints in Litestar for SPA-only JSON APIs that do not exchange HTML fragments. This approach is designed specifically for server-rendered components and partial page updates.