Htmx 2.0.0-preview.1

This is a prerelease version of Htmx.
dotnet add package Htmx --version 2.0.0-preview.1
                    
NuGet\Install-Package Htmx -Version 2.0.0-preview.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Htmx" Version="2.0.0-preview.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Htmx" Version="2.0.0-preview.1" />
                    
Directory.Packages.props
<PackageReference Include="Htmx" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Htmx --version 2.0.0-preview.1
                    
#r "nuget: Htmx, 2.0.0-preview.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Htmx@2.0.0-preview.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Htmx&version=2.0.0-preview.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Htmx&version=2.0.0-preview.1&prerelease
                    
Install as a Cake Tool

htmx.NET

HTMX Logo

Htmx Htmx.TagHelpers

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

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages (7)

Showing the top 5 NuGet packages that depend on Htmx:

Package Downloads
Mostlylucid.BotDetection.UI

Real-time bot detection dashboard with SignalR and DaisyUI. Includes sb-badge, sb-confidence, sb-gate, sb-honeypot, sb-human, sb-risk, sb-signal, and sb-summary Tag Helpers plus View Components for embedding detection results in ASP.NET Core views.

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.

GitHub repositories (4)

Showing the top 4 popular GitHub repositories that depend on Htmx:

Repository Stars
dodyg/practical-aspnetcore
Practical samples of ASP.NET Core 11, 10, 9, 8.0, 7.0, 6.0, 5.0, 3.1, 2.2, and 2.1,projects you can use. Readme contains explanations on all projects.
AscensionGameDev/Intersect-Engine
Intersect provides a complete game development suite for creating 2d mmorpgs with no programming experience required!
westonwalker/BlazorMinimalAPI
cwoodruff/htmxRazor
htmx Components for ASP.NET Core
Version Downloads Last Updated
2.0.0-preview.1 179 11/2/2026
1.12.0 273,168 3/2/2026
1.11.0 736 2/27/2026
1.10.0 5,951 2/13/2026
1.9.0 104,669 9/29/2025
1.8.3 33,815 7/12/2025
1.8.2 18,765 5/19/2025
1.8.1 183,553 11/15/2024
1.8.0 107,411 4/22/2024
1.7.0 55,622 2/9/2024
1.6.3 20,474 1/3/2024
1.6.2 809 1/2/2024
1.6.1 31,589 10/23/2023
1.6.0 4,162 10/16/2023
1.5.0 2,949 10/4/2023
1.4.0 5,657 9/27/2023
1.3.1 14,348 8/16/2023
1.3.0 6,875 8/11/2023
1.2.0 11,082 7/24/2023
1.1.3 55,480 5/31/2023
Loading failed

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.