Escape the SPA Trap: Adding Interactivity to ASP.NET Razor Pages with HTMX
Escape the SPA Trap: Adding Interactivity to ASP.NET Razor Pages with HTMX If you’ve been in the .NET ecosystem for a while, you’ve likely felt the pressure to "SPA-ify" everything. We moved from R...

Source: DEV Community
Escape the SPA Trap: Adding Interactivity to ASP.NET Razor Pages with HTMX If you’ve been in the .NET ecosystem for a while, you’ve likely felt the pressure to "SPA-ify" everything. We moved from Razor Views to React, then to Blazor, and now we’re circling back. Why? Because for many data-driven business applications, the complexity of a full client-side framework is overkill. Enter HTMX. It’s not a new framework; it’s a different way of thinking. By leveraging standard HTML attributes, you can add AJAX, CSS Transitions, WebSockets, and Server-Sent Events directly into your markup. Why Razor Pages + HTMX? Razor Pages are already a fantastic way to organize your .NET web apps. They use a PageModel to handle logic and a .cshtml file for rendering. When you add HTMX, you get: No Build Step: No more npm install, webpack, or vite configurations for your main UI. Type Safety: Your server-side C# code remains the source of truth. Simplicity: You’re just returning HTML fragments instead of JSO