# htmx Web App taste of a backend developer who wants interactivity without a SPA
- Render HTML on the server and use htmx for interactivity before reaching for React or another client-side framework. Confidence: 0.85
- Make every page work as plain links and forms first, then layer hx-get, hx-post and hx-boost on top as progressive enhancement. Confidence: 0.85
- Return HTML fragments from endpoints, never JSON that the client has to turn into markup. Confidence: 0.90
- Keep fragments as small partial templates that the full page template also includes, so there is one source of markup per component. Confidence: 0.90
- Check the HX-Request header on the server to decide between returning a fragment and the full page for the same URL. Confidence: 0.85
- Prefer hx-target with a stable id and hx-swap="outerHTML" so the swapped element can be swapped again later. Confidence: 0.80
- Use hx-push-url for navigation-like swaps so the back button and shareable URLs keep working. Confidence: 0.85
- Put hx-boost="true" on the body or main nav for cheap SPA-like navigation instead of wiring every link by hand. Confidence: 0.70
- Use hx-swap-oob for secondary updates such as a cart count or flash message instead of a second request. Confidence: 0.75
- Trigger client events from the server with the HX-Trigger response header rather than inline script in fragments. Confidence: 0.80
- Show progress with hx-indicator and the htmx-request CSS class; no hand-written loading-state JavaScript. Confidence: 0.85
- Add hx-disabled-elt on submit buttons so double clicks cannot post a form twice. Confidence: 0.80
- Validate forms on the server and re-render the form fragment with inline errors and the user's values kept. Confidence: 0.90
- Use hx-trigger="keyup changed delay:300ms" for live search, and cancel stale requests with hx-sync. Confidence: 0.80
- Send the CSRF token for every non-GET request through hx-headers on the body or a hidden form field. Confidence: 0.95
- Escape all output in templates by default and never swap in user-supplied HTML. Confidence: 0.95
- Return 422 with the re-rendered form on validation errors and configure htmx to swap that response. Confidence: 0.75
- Use HX-Redirect or HX-Location after a successful POST instead of returning a page fragment for the next screen. Confidence: 0.75
- Keep small client-only behavior (toggles, dropdowns, copy buttons) in Alpine.js or a few lines of vanilla JS, not in extra round trips. Confidence: 0.70
- Vendor a pinned htmx file or load it with a subresource integrity hash; no unpinned CDN script tags. Confidence: 0.85
- Avoid hx-on handlers with long inline scripts; move logic into a small named JS function. Confidence: 0.75
- Test endpoints by asserting on returned HTML with a parser, and cover the main flows with Playwright end-to-end tests. Confidence: 0.80
- Reach for a client-side framework only for genuinely app-like screens such as rich editors or offline-first views. Confidence: 0.70
Comments & Questions (0)
No comments yet
Be the first to comment!