Run the examples
The guides build small examples step by step. The repository also includes a demo with separate pages for request detection, response headers, Tag Helpers, events, polling, and antiforgery.
Run the demo
Install the .NET 10 SDK or later, then run:
git clone https://github.com/rameel/ramstack.htmxtoolkit.git
cd ramstack.htmxtoolkit
dotnet run --project samples/Ramstack.HtmxToolkit.Demo --no-launch-profile -- --urls http://localhost:5000 --environment Development
Open http://localhost:5000. This command uses HTTP for local development, so a development HTTPS certificate is not needed. The demo loads HTMX from a CDN and requires a network connection for that script.
The demo currently selects HTMX 4.x. The introductory tutorials use HTMX 2.x, the toolkit default.
To try another supported version, change both UseHtmxV4(...) in Program.cs and the HTMX script in
Pages/Shared/_Layout.cshtml. Review Version compatibility before changing
version-specific options such as NoSwap.
Find an example
Each Razor Page has a .cshtml file for the browser markup and a .cshtml.cs file for its handlers.
Start with the linked page, then open its code-behind file in the same directory.
| Task | Demo page | Related guide |
|---|---|---|
| Generate a page-handler URL | UrlTagHelper | Tag Helpers |
| Send route values | RouteData | Routes and dictionaries |
| Send values and custom headers | HtmxVals, Headers | Tag Helpers |
| Set request options | RequestOptions | Configure one request |
| Detect HTMX and boosted requests | HtmxRequest, Boosted | Requests |
| Use MVC attributes | InventoryController | MVC action selection |
| Change the response target | FluentResponse | Responses |
| Trigger another update | ServerEvents | Forms and events tutorial |
| Poll until work completes | Polling | Polling recipe |
| Submit a protected form | Antiforgery | Antiforgery |
Inspect the browser behavior
Keep the Network panel open while using each example. Compare the rendered hx-* attributes with the Razor
source, then inspect the request URL, form values, and HX-* response headers.
These are small demonstrations, not production data flows. Add your own persistence, authorization, and error handling when adapting them. For a complete introduction with all files shown in order, start with Getting started.