<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/get-started-with-htmx-4-uuwtjapxc" -->

---
title: Get started with htmx 4 | daily.dev
description: A tutorial walkthrough of htmx, the library that lets developers add dynamic, server-driven interactivity to web pages using custom HTML attributes instead of...
canonical: https://daily.dev/posts/get-started-with-htmx-4-uuwtjapxc
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Get started with htmx 4 | daily.dev
og:description: A tutorial walkthrough of htmx, the library that lets developers add dynamic, server-driven interactivity to web pages using custom HTML attributes instead of...
og:url: https://daily.dev/posts/get-started-with-htmx-4-uuwtjapxc
og:image: https://api.daily.dev/og/posts/uuwtjaPxc.png
og:image:alt: Get started with htmx 4
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Get started with htmx 4

**[InfoWorld](https://daily.dev/sources/infoworld)** · 10 min read · 0 upvotes · 0 comments

## Summary

A tutorial walkthrough of htmx, the library that lets developers add dynamic, server-driven interactivity to web pages using custom HTML attributes instead of hand-written JavaScript. It covers installation, basic hx- attributes like hx-post and hx-target, event triggers via hx-trigger, targeting elements with extended selectors, swapping strategies via hx-swap, link boosting with hx-boost, streaming responses through SSE, multipart, and websocket extensions, other pre-written extensions, hooking custom JavaScript into htmx events, and common caveats such as manually wiring fragments with htmx.process() and handling JSON responses instead of HTML fragments.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.infoworld.com/article/4221778/get-started-with-htmx-4.html>

## Questions this post answers

### How do I show a loading indicator while an htmx request is in progress?

Add the hx-indicator attribute to the element triggering the request, pointing to a CSS selector for the indicator element, and give that element the htmx-indicator class. Htmx automatically reveals the element while the request is pending and hides it again once the response arrives, giving users visual feedback for slow requests.

_Developers wiring up async feedback in htmx pages can browse similar hands-on guides on daily.dev._

### How do I make an htmx button only fire when the shift key is held down?

Use the hx-trigger attribute with a value like click[shiftKey] on the button. This restricts the request to firing only when the click event occurs while the Shift key is pressed, which is a useful safeguard for preventing accidental destructive actions such as deletes.

_Anyone hardening interactive forms against accidental clicks can find more htmx patterns on daily.dev._

### How do I stream incremental updates into an htmx page using websockets?

Install the hx-ws extension and add hx-ws:connect to a container element specifying the websocket endpoint, along with hx-target and hx-swap="append" to control where and how incoming messages are added. A nested form with hx-ws:send handles sending data back through the same connection, letting new messages append to the page as they arrive.

_Developers building real-time features can compare streaming approaches like this on daily.dev._

## Similar posts on daily.dev

- [HTMX](https://daily.dev/posts/htmx-mlto71ou4) · Wawandco · 0 upvotes · 0 comments
- [A deep dive into HTMX](https://daily.dev/posts/a-deep-dive-into-htmx-uuhadafnq) · Flavio Copes · 1 upvotes · 0 comments
- [Going deeper with htmx 4 — combining htmx and JavaScript](https://daily.dev/posts/going-deeper-with-htmx-4-combining-htmx-and-javascript-azbc6dgbe) · InfoWorld · 1 upvotes · 0 comments
- [Please Just Fucking Try HTMX](https://daily.dev/posts/please-just-fucking-try-htmx-ncu8zbk1v) · Lobsters · 21 upvotes · 3 comments

---

Tags: [#webdev](https://daily.dev/tags/webdev), [#javascript](https://daily.dev/tags/javascript), [#htmx](https://daily.dev/tags/htmx), [#server-sent-events](https://daily.dev/tags/server-sent-events)

[View this post on daily.dev](https://daily.dev/posts/get-started-with-htmx-4-uuwtjapxc)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Get started with htmx 4","url":"https://daily.dev/posts/get-started-with-htmx-4-uuwtjapxc","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/get-started-with-htmx-4-uuwtjapxc"},"datePublished":"2026-09-23T09:04:09.924Z","dateModified":"2026-09-23T09:05:37.595Z","description":"A tutorial walkthrough of htmx, the library that lets developers add dynamic, server-driven interactivity to web pages using custom HTML attributes instead of...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/727f186276e3d0cacbf312d746d179ed?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/727f186276e3d0cacbf312d746d179ed?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"InfoWorld","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"InfoWorld","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/bf6d68a999064029b0bb09aa6268f1f3","url":"https://daily.dev/sources/infoworld"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/get-started-with-htmx-4-uuwtjapxc","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"webdev,javascript,htmx,server-sent-events","timeRequired":"PT10M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"InfoWorld","item":"https://daily.dev/sources/infoworld"},{"@type":"ListItem","position":3,"name":"Get started with htmx 4"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/get-started-with-htmx-4-uuwtjapxc#faq","mainEntity":[{"@type":"Question","name":"How do I show a loading indicator while an htmx request is in progress?","acceptedAnswer":{"@type":"Answer","text":"Add the hx-indicator attribute to the element triggering the request, pointing to a CSS selector for the indicator element, and give that element the htmx-indicator class. Htmx automatically reveals the element while the request is pending and hides it again once the response arrives, giving users visual feedback for slow requests. Developers wiring up async feedback in htmx pages can browse similar hands-on guides on daily.dev."}},{"@type":"Question","name":"How do I make an htmx button only fire when the shift key is held down?","acceptedAnswer":{"@type":"Answer","text":"Use the hx-trigger attribute with a value like click[shiftKey] on the button. This restricts the request to firing only when the click event occurs while the Shift key is pressed, which is a useful safeguard for preventing accidental destructive actions such as deletes. Anyone hardening interactive forms against accidental clicks can find more htmx patterns on daily.dev."}},{"@type":"Question","name":"How do I stream incremental updates into an htmx page using websockets?","acceptedAnswer":{"@type":"Answer","text":"Install the hx-ws extension and add hx-ws:connect to a container element specifying the websocket endpoint, along with hx-target and hx-swap=\"append\" to control where and how incoming messages are added. A nested form with hx-ws:send handles sending data back through the same connection, letting new messages append to the page as they arrive. Developers building real-time features can compare streaming approaches like this on daily.dev."}}]}
```

