Skip to content
Tutorials Center
My learning

Topics

HTMX and Alpine.js Tutorial

Learn HTMX and Alpine.js step by step: 28 lessons in 8 chapters with examples, quizzes, diagrams and projects.

Start learning →

of lessons completed

Getting Started

  1. 1 HTML-first interactivity: HTMX and Alpine.js Meet HTMX and Alpine.js: two small libraries that add server round trips and local state to plain HTML, with no build step and no JSON API.
  2. 2 Setting Up: CDN, Versions and the In-Page Mock Server Add HTMX 2 and Alpine.js 3 with pinned CDN script tags, learn defer and load order, and read the tiny mock server every example in this track uses.

Alpine.js Basics

  1. 3 Reactive State with x-data Learn Alpine.js state: x-data objects, x-text, x-show, @click, methods, getters, component scope, several components per page and x-init.
  2. 4 Binding Attributes, Classes and Styles Bind HTML attributes with Alpine.js x-bind and the colon shorthand: dynamic classes, inline styles, disabled buttons, boolean attributes and x-model basics.
  3. 5 Conditionals and Loops with x-if and x-for Render conditionally with x-if and repeat markup with x-for in Alpine.js: template tags, keys, index, nested loops, filtering with a getter and common mistakes.
  4. 6 Forms and x-model Master Alpine.js forms: x-model on text, checkbox, radio, select and textarea, the .number .trim .lazy .debounce modifiers, live validation and @submit.prevent.
  5. 7 Events, Modifiers and Refs Handle events in Alpine.js with @ listeners and modifiers like .prevent, .outside and .debounce, reach elements with x-ref, and talk between components with $dispatch.

Alpine.js Going Further

  1. 8 Magic Properties, x-effect and Transitions Go further with Alpine.js: watch data with $watch, run code after updates with $nextTick, use x-effect, animate with x-transition, avoid flashes with x-cloak, and build modals with x-teleport.
  2. 9 Reusable Components, Alpine.data and Stores Stop repeating inline x-data. Learn Alpine.data for reusable components with parameters, Alpine.store for global state, x-modelable, and the alpine:init event.
  3. 10 Alpine Plugins and Other Features Tour the official Alpine.js plugins with live demos of collapse, intersect and mask, plus x-id, x-ignore and Alpine.bind for reusing attribute sets.

HTMX Basics

  1. 11 Your First HTMX Request Send your first HTMX request with hx-get, choose where the reply goes with hx-target, see the default swap, and learn why the server answers with HTML, not JSON.
  2. 12 Verbs, Triggers and Parameters Use hx-get, hx-post, hx-put, hx-patch and hx-delete, control when requests fire with hx-trigger, and decide what is sent with hx-vals, hx-include and hx-params.
  3. 13 Targets and Swap Strategies Control where HTMX puts server HTML: hx-target selectors, every hx-swap strategy, swap modifiers, hx-select and out-of-band updates with hx-swap-oob.
  4. 14 Forms, Validation and Submissions Submit forms with hx-post, return validation errors as HTML, validate fields on blur, disable buttons with hx-disabled-elt and confirm risky actions.

HTMX in Practice

  1. 15 Loading States, Indicators and Feedback Show spinners with hx-indicator and the htmx-request class, animate swaps with htmx-swapping and htmx-settling, and stop race conditions with hx-sync.
  2. 16 Common Interaction Patterns Build the interactions every site needs with HTMX: live search, click to edit, inline delete, load more, infinite scroll, lazy loading, polling, tabs and bulk actions.
  3. 17 Events, Headers and JavaScript Integration Hook into HTMX with htmx:configRequest and htmx:beforeSwap, steer responses with HX-Trigger, HX-Retarget and HX-Reswap, and call htmx.ajax and htmx.process.
  4. 18 URLs, History and Navigation Keep the address bar and Back button working with HTMX: hx-push-url, hx-replace-url, history snapshots, hx-boost and URLs that work without JavaScript.

HTMX and Alpine Together

  1. 19 Using HTMX and Alpine.js Together Combine HTMX and Alpine.js safely: decide who owns which state, use Alpine inside swapped HTML, trigger requests with $dispatch and build server-filled modals.
  2. 20 Server-Side Setup: Fragments, Partials and Security Return HTML fragments from Laravel, Django, Express or Flask, detect HX-Request, send CSRF tokens, escape output, and lock down HTMX and Alpine.js.

Projects

  1. 21 Project: Todo List with HTMX and Alpine Build a todo list where the server owns the data: add, toggle and delete with HTMX, edit in place and filter with Alpine.js, and update counts out of band.
  2. 22 Project: Live Search and Filterable Table Build a live-search table with HTMX and Alpine.js: debounced search, sortable columns, pagination with hx-get, column toggles and an empty state.
  3. 23 Project: Shopping Cart and Product Quick View Build a shopping cart with HTMX and Alpine.js: add to cart with out-of-band badge updates, quantity steppers, server-computed totals and a quick-view modal.
  4. 24 Project: Dashboard with Polling, Tabs and Toasts Build a dashboard with HTMX and Alpine.js: polling widgets with hx-trigger every, lazy-loaded tab panels, and toast notifications driven by HX-Trigger events.

Practice and Review

  1. 25 Exercises with Solutions Twelve graded HTMX and Alpine.js exercises with runnable starters, hidden solutions and broken snippets to debug. Practice what you learned, then check your work.
  2. 26 Common Mistakes and Debugging Fix the usual HTMX and Alpine.js bugs: missing x-data, x-for without template, x-cloak flashes, bad hx-target, 4xx and 5xx not swapping, plus debugging tips.
  3. 27 Interview Questions 30 HTMX and Alpine.js interview questions with concise answers: hypermedia, swapping, triggers, reactivity, stores, security, testing and when to pick them.
  4. 28 Cheat Sheet One-page HTMX and Alpine.js cheat sheet: attributes, triggers, swap values, headers, events, directives, magics and plugins, with two quick live checks.