Debian Codegraph @

www/src/content/index.mdx

raw
1 ---
2 title: "htmx"
3 description: "htmx gives you access to AJAX, CSS Transitions, WebSockets and Server Sent Events directly in HTML, using attributes, so you can build modern user interfaces with the simplicity and power of hypertext"
4 ---
5 import { getFile } from '../lib/content';
6 import CDNGenerator from "../components/CDNGenerator.astro";
7 import EasterEggs from "../components/EasterEggs.astro";
8 import Sponsors from "../components/Sponsors.astro";
9 import Hero from "../components/Hero.astro";
10 import { Image } from 'astro:assets';
11 import bookCoverHard from '../assets/img/cover.png';
12 import bookCoverSoft from '../assets/img/cover2.png';
13 export const sponsorsFile = await getFile('sponsors.yaml');
14 export const sponsors = (sponsorsFile?.frontmatter || []).map(s => ({
15 ...s,
16 url: s.tracking !== false
17 ? `${s.url}?utm_source=htmx&utm_medium=sponsorship&utm_campaign=${s.tier}-sponsor-${new Date().getFullYear()}`
18 : s.url,
19 }));
20
21 <div class="not-prose">
22
23 <EasterEggs/>
24
25 <Hero/>
26
27 </div>
28
29
30 <div class="prose-sm sm:prose-base prose-htmx dark:prose-invert max-w-2xl mx-auto px-4 sm:px-6 lg:px-8 pt-8 sm:pt-16 pb-0">
31
32 ## motivation
33
34 - Why should only [`<a>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a) & [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form) be able to make HTTP requests?
35 - Why should only [`click`](https://developer.mozilla.org/en-US/docs/Web/API/Element/click_event) & [`submit`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/submit_event) events trigger them?
36 - Why should only [`GET`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET) & [`POST`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST) methods be [available](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods)?
37 - Why should you only be able to replace the **entire** screen?
38
39 By removing these constraints, htmx completes HTML as a [hypertext](https://en.wikipedia.org/wiki/Hypertext).
40
41 ## quick example
42
43 ```html
44 <button hx-post="/clicked" hx-swap="outerHTML">
45 Click Me
46 </button>
47 ```
48
49 When clicked, [`hx-post`](/reference/attributes/hx-post) sends a `POST` to `/clicked` and [`hx-swap`](/reference/attributes/hx-swap) replaces the button with the response. No JavaScript.
50
51 ## book
52
53 [Hypermedia Systems](https://hypermedia.systems) covers building [Hypermedia-Driven Applications](/essays/hypermedia-driven-applications) with htmx. Free online.
54
55 <a href="https://hypermedia.systems" target="_blank" rel="noopener noreferrer" class="group block not-prose w-fit mx-auto font-chicago text-sm text-center text-neutral-900 dark:text-neutral-100 interact:text-blue-700 dark:interact:text-blue-300 interact:underline">
56 <div class="flex gap-8 justify-center mb-3">
57 <Image src={bookCoverHard} alt="Hypermedia Systems (hardcover)" width={240} class="rounded-sm border border-neutral-200 dark:border-neutral-800 group-interact:-translate-y-1 transition" />
58 <Image src={bookCoverSoft} alt="Hypermedia Systems (softcover)" width={240} class="rounded-sm border border-neutral-200 dark:border-neutral-800 group-interact:-translate-y-1 transition" />
59 </div>
60 Hypermedia Systems
61 </a>
62
63 ## sponsors
64
65 Thank you to all our generous [sponsors](https://github.com/sponsors/bigskysoftware?o=esb)!
66
67 <Sponsors sponsors={sponsors} />
68
69 </div>
70
71 <div class="not-prose text-center py-8 space-y-2">
72 <p class="text-neutral-600 dark:text-neutral-400 font-chicago text-sm">
73 htmx is the successor to <a href="http://intercoolerjs.org"
74 class="text-blue-600 dark:text-blue-350 interact:underline interact:text-blue-700 dark:interact:text-blue-300">intercooler.js</a>
75 </p>
76 <p class="text-neutral-500 dark:text-neutral-500 text-sm">
77 ʕ •ᴥ•ʔ made in montana
78 </p>
79 </div>