Upgrading to Rizzy 6

Rizzy 6 targets htmx 4.0.1+ and .NET 10. This page lists the steps most apps need. The complete reference, with every breaking change and the audit finding behind it, is the upgrade guide in the Rizzy repository, and the changelog summarizes the release.

Upgrade steps

  1. Update the packages. Reference Rizzy 6.x; it brings the matching Rizzy.Htmx. If you use the npm package, install @jalexsocial/rizzy 6.x and htmx.org 4.0.1 or later (htmx.org is now a peer dependency).

  2. Replace <HeadOutlet /> with <RzHeadOutlet /> in your root layout, and replace your htmx and Rizzy script tags with <RzScripts /> right after it (it loads htmx 4 with SRI, rizzy.js and any extensions you enable):

    AppLayout.razor
    <head>
        <RzHeadOutlet />
        <RzScripts />
    </head>

    Rizzy 5 added the htmx config meta tag (and the antiforgery token) through <HeadContent>, and a page with its own <HeadContent> silently removed it. See Head.

  3. Simplify registration. AddRizzy() now registers htmx support and Razor components; you can drop AddRazorComponents() and keep AddHtmx(...) only to change the htmx configuration.

  4. Register MVC with AddControllersWithViews() if your actions use [ValidateAntiForgeryToken]. Rizzy no longer injects MVC’s antiforgery filters through reflection.

  5. Run the htmx upgrade checker on your templates:

    npx -p htmx.org@4 upgrade-check --ext .razor --ext .cshtml ./
  6. Click through the app with the browser console open. htmx 4 logs every error, and Rizzy warns about a missing config tag or a script/server version mismatch.

Markup changes (htmx 4)

htmx 2htmx 4
Attributes inherited implicitlyAdd :inherited (hx-boost:inherited, hx-target:inherited, …) or set HtmxConfig.ImplicitInheritance = true
hx-ext="..."Removed: extensions register when their script loads. Enable them with HtmxConfig.UseExtensions(...); <RzScripts /> loads them and Rizzy keeps the allow-list in step
hx-disable to skip processinghx-ignore
History cache in localStorageNo cache: back/forward re-fetch the page. Mark the element to restore with hx-history-elt, or set HtmxConfig.History = HtmxHistoryMode.Reload
4xx/5xx responses not swappedSwapped by default. Use it for validation (status 422) and app.UseHtmxErrorHandling() for server errors, or set HtmxConfig.NoSwap = [204, 304, "4xx", "5xx"]
queue trigger modifierRemoved: use hx-sync

Behavior changes in Rizzy

  • Layouts: fragments (no layout) are returned only for htmx requests that target one element. Boosted body swaps, hx-select and back/forward restores get the full page. See Layouts.
  • Validation: return status 422 with the re-rendered form (Response.Htmx().ValidationFailed()); htmx 4 swaps it. RzModelStateProvider (not RzInitialValidator) shows ModelState errors, and RzController passes its ModelState automatically. See Validation.
  • Raw markup is explicit: AddSwappableContent, AddRawContent and AddChildContent take a MarkupString; use AddSwappableText/AddChildText for text, which is HTML-encoded.
  • Streaming rendering cooperates with htmx core: swaps, HX-* headers, hx-status and triggers work while updates stream in. See Streaming.
  • CSP nonces: server-rendered scripts in htmx responses run under a nonce-based policy while injected ones stay blocked; GenerateStyleNonce is gone. See Content Security Policy.
  • Confirm dialogs: hx-confirm uses the browser’s confirm() unless a custom dialog handles rz:confirm-dialog.
  • [RizzyParameterize] works in your own projects: the source generator ships in the Rizzy package.