How to upgrade between xhtmlx versions. Use the CLI tool for automated migration.
The fastest way to migrate is the built-in CLI tool:
npx xhtmlx-migrate --from=1 --to=2 src/
Preview changes first with --dry-run, or rollback with --reverse.
# Preview changes without modifying files npx xhtmlx-migrate --dry-run --from=1 --to=2 src/ # Rollback if something breaks npx xhtmlx-migrate --from=1 --to=2 --reverse src/ # Show all migration rules npx xhtmlx-migrate --list-rules --from=1 --to=2
| v1 (old) | v2 (new) | Notes |
|---|---|---|
| xh-bind | xh-model | Two-way binding renamed for clarity |
| xh-loading | xh-indicator | Loading indicator renamed to match htmx convention |
| Attribute | v1 value | v2 value |
|---|---|---|
| xh-swap | "replace" | "outerHTML" |
| Change | Details |
|---|---|
| xh-ws requires xh-trigger | WebSocket elements now need explicit xh-trigger="message". Previously auto-triggered. |
| Strict equality for xh-model | Radio buttons and selects use === instead of ==. Ensure data types match option values (e.g. "1" not 1). |
xh-model — two-way data binding (pre-fill, auto-collect, live reactivity)xh-class-* — toggle CSS classes based on dataxh-show / xh-hide — toggle visibilityxh-on-* — declarative event handlersxh-push-url / xh-replace-url — browser historyxh-ws / xh-ws-send — WebSocket supportxh-boost — enhance links and formsxh-cache — response caching with TTLxh-retry — automatic retry with backoffxh-validate — declarative form validationxh-i18n — internationalizationxh-router / xh-route — SPA routingxh-focus — focus management after swapxh-template-mobile / xh-template-tablet — responsive templatesxh-name — named inline templatesxhtmlx.directive(), xhtmlx.hook(), xhtmlx.transform()xhtmlx.switchVersion()xhtmlx.config.cspSafe = truenpx xhtmlx-migrate --dry-run --from=1 --to=2 src/npx xhtmlx-migrate --from=1 --to=2 src/git revert or npx xhtmlx-migrate --reverse --from=1 --to=2 src/For zero-downtime deployment, use xhtmlx.switchVersion() instead of migrating HTML files:
// Deploy new templates alongside old ones
// /ui/v1/templates/... (current)
// /ui/v2/templates/... (new)
// Switch all widgets to v2 templates
xhtmlx.switchVersion("v2");
// Rollback if needed
xhtmlx.switchVersion("v1");
This changes the template prefix at runtime without modifying any HTML files. See switchVersion API docs.