htmx.NET
Typed server-side helpers for htmx 4 in ASP.NET Core.
dotnet add package Htmx --prereleasedotnet add package Htmx.TagHelpers --prereleasehtmx sends its state in request headers and reads it back from response headers. htmx.NET turns both sides into typed C# — so you detect htmx requests, read the triggering element, set HX-* response headers, and generate URLs from ASP.NET routing, instead of parsing and concatenating strings by hand.
An example
Section titled “An example”Read the incoming htmx request and answer with typed response headers, instead of parsing strings and building JSON by hand.
// Detect an htmx request and read the element that triggered it.if (Request.IsHtmx(out var htmx)){ // e.g. "save-button" var id = htmx.SourceElement?.Id; // Full or Partial var type = htmx.RequestType;}
// Set HX-* response headers fluently instead of building strings.Response.Htmx(h => h .PushUrl("/items/5") .WithTrigger("saved", new { id = 5 }));Explore the docs
Section titled “Explore the docs”Get startedInstall the packages, wire up the tag helpers, and answer your first htmx request.
GuidesRequest detection, response headers, tag helpers, antiforgery, caching, and morph.
ReferenceHeader-by-header tables and the htmx 4 behavior this library implements.
SamplesRunnable demos for every feature, with the exact server code beside each one.
Migration (v1 → v2)Upgrade from htmx 2 to htmx 4: removed APIs, renames, and the client-script step.
Previous version (v1.x)Documentation for the htmx 2 line of htmx.NET.