khalidabuhakmeh/Htmx.Net
소개
HttpResponse와 HttpRequest에 확장 메서드를 추가해 Htmx를 더 쉽게 사용할 수 있습니다.
기타 프로젝트측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
Originalhtmx.NET

[!IMPORTANT] 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.
[!NOTE] 2.0.0 is in preview. Install it with
--prereleaseand 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/[email protected]/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. - More samples: Twelve Days of htmx-mas — a Christmas-themed ASP.NET Core app with 12 htmx demos.
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.
관련 프로젝트 살펴보기
불러오는 중…