Htmx.TagHelpers
2.0.0-preview.1
dotnet add package Htmx.TagHelpers --version 2.0.0-preview.1
NuGet\Install-Package Htmx.TagHelpers -Version 2.0.0-preview.1
<PackageReference Include="Htmx.TagHelpers" Version="2.0.0-preview.1" />
<PackageVersion Include="Htmx.TagHelpers" Version="2.0.0-preview.1" />
<PackageReference Include="Htmx.TagHelpers" />
paket add Htmx.TagHelpers --version 2.0.0-preview.1
#r "nuget: Htmx.TagHelpers, 2.0.0-preview.1"
#:package Htmx.TagHelpers@2.0.0-preview.1
#addin nuget:?package=Htmx.TagHelpers&version=2.0.0-preview.1&prerelease
#tool nuget:?package=Htmx.TagHelpers&version=2.0.0-preview.1&prerelease
htmx.NET
htmx.NET 2.x targets htmx 4 only. It is a breaking change from the 1.x line (which supports htmx 1.x/2.x). See the Migration guide. Staying on htmx 1/2? Use htmx.NET 1.x and the previous-version docs.
2.0.0 is in preview. Install it with --prerelease and kick the tires — then please share
feedback on GitHub issues before the stable release.
Server-side ASP.NET Core helpers that make working with htmx from HttpRequest
and HttpResponse simpler, plus Tag Helpers for URL generation, htmx-config, and antiforgery.
📖 Full documentation: khalidabuhakmeh.github.io/Htmx.Net
Install
While 2.x is in preview, add --prerelease:
dotnet add package Htmx --prerelease
dotnet add package Htmx.TagHelpers --prerelease
Requires htmx 4 on the client:
<script src="https://unpkg.com/htmx.org@4.0.0/dist/htmx.min.js" defer></script>
Quick start
Detect htmx requests and return a partial instead of a full page:
// in a Razor Page or controller
return Request.IsHtmx()
? Partial("_Form", this)
: Page();
Read typed htmx request headers (the HX-Source element reference, request type, and more):
if (Request.IsHtmx(out var headers))
{
var source = headers.SourceElement; // tag#id, e.g. button#save
var kind = headers.RequestType; // Full or Partial
}
Set htmx response headers with a fluent API:
Response.Htmx(h => h
.PushUrl("/new-url")
.Retarget("#result")
.Reswap(HtmxSwap.OuterMorph)
.WithTrigger("saved", new { id = 42 }));
Tag Helpers — add to _ViewImports.cshtml:
@addTagHelper *, Htmx.TagHelpers
Generate ASP.NET Core URLs straight onto htmx attributes, and configure htmx + antiforgery:
<meta name="htmx-config" includeAspNetAntiforgeryToken="true" defaultSwap="innerHTML" />
<button hx-get hxn-page="Index" hxn-page-handler="Snippet" hx-target="#result">
Load
</button>
// Program.cs — expose the antiforgery integration script
app.MapHtmxAntiforgeryScript();
Documentation
- Getting started
- Guides — request detection, response headers, triggers, config, Tag Helpers, antiforgery, caching, partials & morph
- Migration guide (v1 → v2)
- Previous version (v1.x)
- Samples:
samples/Htmx4.Sampledemonstrates every feature with integration and Playwright E2E tests.
New to htmx with ASP.NET Core? See the JetBrains guide to getting started with htmx for ASP.NET Core developers.
License
Copyright (c) Khalid Abuhakmeh. Licensed under the MIT License — see License.md.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages (6)
Showing the top 5 NuGet packages that depend on Htmx.TagHelpers:
| Package | Downloads |
|---|---|
|
IPWhitelist
Package Description |
|
|
htmxRazor
Server-rendered UI components for ASP.NET Core with first-class htmx integration. 80+ Tag Helper components across 11 categories — buttons, forms, data tables, navigation, overlays, feedback, and more — all styled with CSS custom properties and fully accessible. |
|
|
aadog.WebUtils
Package Description |
|
|
Kentico.Xperience.AiraUnified
Xperience by Kentico AI chat and upload companion application. |
|
|
Htmx.Components
A comprehensive ASP.NET Core library for building interactive web applications with server-side rendering and HTMX integration. Provides ready-to-use components, state management, and built-in authorization with minimal JavaScript. |
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on Htmx.TagHelpers:
| Repository | Stars |
|---|---|
|
AscensionGameDev/Intersect-Engine
Intersect provides a complete game development suite for creating 2d mmorpgs with no programming experience required!
|
|
|
cwoodruff/htmxRazor
htmx Components for ASP.NET Core
|
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.0-preview.1 | 175 | 11/2/2026 |
| 1.12.0 | 243,230 | 3/2/2026 |
| 1.11.0 | 464 | 2/27/2026 |
| 1.10.0 | 6,761 | 2/13/2026 |
| 1.9.0 | 83,391 | 9/29/2025 |
| 1.8.3 | 30,955 | 7/12/2025 |
| 1.8.2 | 15,451 | 5/19/2025 |
| 1.8.1 | 147,366 | 11/15/2024 |
| 1.8.0 | 81,562 | 4/22/2024 |
| 1.7.0 | 53,531 | 2/9/2024 |
| 1.6.3 | 8,296 | 1/3/2024 |
| 1.6.2 | 743 | 1/2/2024 |
| 1.6.1 | 26,802 | 10/23/2023 |
| 1.6.0 | 4,030 | 10/16/2023 |
| 1.5.0 | 5,610 | 10/4/2023 |
| 1.4.0 | 705 | 9/27/2023 |
| 1.3.1 | 13,704 | 8/16/2023 |
| 1.3.0 | 5,761 | 8/11/2023 |
| 1.2.0 | 10,897 | 7/24/2023 |
| 1.1.3 | 55,813 | 5/31/2023 |
2.0.0 targets htmx 4 and is a breaking change from the 1.x line. See the migration guide: https://khalidabuhakmeh.github.io/Htmx.Net/migration/v1-to-v2/ and CHANGELOG.md.