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
Update the packages. Reference
Rizzy6.x; it brings the matchingRizzy.Htmx. If you use the npm package, install@jalexsocial/rizzy6.x andhtmx.org4.0.1 or later (htmx.orgis now a peer dependency).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.Simplify registration.
AddRizzy()now registers htmx support and Razor components; you can dropAddRazorComponents()and keepAddHtmx(...)only to change the htmx configuration.Register MVC with
AddControllersWithViews()if your actions use[ValidateAntiForgeryToken]. Rizzy no longer injects MVC’s antiforgery filters through reflection.Run the htmx upgrade checker on your templates:
npx -p htmx.org@4 upgrade-check --ext .razor --ext .cshtml ./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 2 | htmx 4 |
|---|---|
| Attributes inherited implicitly | Add :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 processing | hx-ignore |
| History cache in localStorage | No 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 swapped | Swapped by default. Use it for validation (status 422) and app.UseHtmxErrorHandling() for server errors, or set HtmxConfig.NoSwap = [204, 304, "4xx", "5xx"] |
queue trigger modifier | Removed: 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-selectand 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(notRzInitialValidator) showsModelStateerrors, andRzControllerpasses itsModelStateautomatically. See Validation. - Raw markup is explicit:
AddSwappableContent,AddRawContentandAddChildContenttake aMarkupString; useAddSwappableText/AddChildTextfor text, which is HTML-encoded. - Streaming rendering cooperates with htmx core: swaps,
HX-*headers,hx-statusand 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;
GenerateStyleNonceis gone. See Content Security Policy. - Confirm dialogs:
hx-confirmuses the browser’sconfirm()unless a custom dialog handlesrz:confirm-dialog. [RizzyParameterize]works in your own projects: the source generator ships in the Rizzy package.