skip to the main content
2024-06-01

.NET+HTMX can be a decent experience

A while ago I made my own version of a flag guessing game: https://games.domi.ninja/flags/
Since this is a simple app, I took the opportunity to find a nice way to use HTMX with .NET.

I sent my HTMX requests to a proper .NET API controller that then renders a hierarchy of ViewComponents which act as reusable website components. The required data is mapped at render time by the caller.

If you are interested in this setup, Source code is available here.

Credits also to Jetbrains for their tutorial series: HTMX for ASP.NET Core Developers, a good starting point for anyone interested. Their rendering setup differs from mine.



For the real-time autocomplete, I turned away from HTMX, because while server round trips for the main input boxes of an app are feasible, the resulting experience would not be good.

I wanted people to be able to play this game on the train etc. without any kind of lag. So I wrote some vanilla Javascript that fetches the country list and displays the autocomplete box.