Server-Driven Web Apps with htmx (Pragmatic Bookshelf)

PragmaticBookshelf
Build modern server-driven web applications using htmx. Whatever programming language you use, you’ll write less (and cleaner) code.

R. Mark Volkmann @mvolkmann

Edited by Don N. Hagist @dhagist

htmx is a library that adds logic and server interaction to HTML; you get the effect of using a front-end SPA framework without writing front-end code. Use any server-side programming language and framework to build server applications with endpoints that simply return snippets of HTML. Dynamically update portions of the current web page from HTTP responses. Add interactivity with JavaScript and libraries such Alpine and _hyperscript. Make your apps more secure by escaping user-supplied content and specifying a Content Security Policy. Go beyond basic HTTP requests with WebSockets and server-sent events.

The htmx JavaScript library gives you a new way to craft web applications. The htmx approach differs significantly from that of the currently popular single-page application (SPA) frameworks; rather than write a bunch of JavaScript, you simply annotate HTML elements before you send them to the browser. The resulting code is easier to understand and modify, and because it downloads less to the browser and doesn’t need JSON creation and parsing, you’ll find it performs better, too.

  • Rethink web application design; write code in any language that simply responds to requests with htmx snippets.
  • Dynamically update portions of the current web page directly from the server.
  • Implement common patterns such as lazy loading, input validation, CSS transitions, active search, optimistic updates, pagination, infinite scroll, polling, and click-to-edit.
  • Add interactivity with JavaScript and libraries such as Alpine and _hyperscript.
  • Use the htmx JavaScript API to simplify DOM operations.
  • Make your web apps more secure: escape user-supplied content, use Subresource Integrity hashes, and enforce a Content Security Policy.
  • Go beyond the basic HTTP request/response pattern with WebSockets and server-sent events.

Discover a simpler way to implement web applications that emphasizes web fundamentals.


Mark Volkmann is a Partner and Distinguished Engineer at Object Computing, Inc. in St. Louis where he has provided software consulting and training since 1996. As a consultant, Mark has assisted many companies with JavaScript, Node.js, htmx, Svelte, React, Vue, Angular, Swift, SwiftUI, and much more.


Don’t forget you can get 35% off with your Devtalk discount! Just use the coupon code “devtalk.com" at checkout :+1:

Latest Threads About This Book Top

Margaret
Ask Me Anything with Mark Volkmann @mvolkmann On February 24 and 25, we are giving you a chance to ask questions of PragProg author M...
New
ralfkret
On page 35 (chapter 3. Developing Endpoints) in the “Your Turn” section it says “In the endpoint, set HX-Target…”. Shouldn’t that be HX-T...
New
jayhowey
@mvolkmann Hi Mark and Authors, In the new Beta 3.0 of the book, on page xiii, in the Foreword section by Carson Gross, in this third p...
New
PragmaticBookshelf
Build modern server-driven web applications using htmx. Whatever programming language you use, you’ll write less (and cleaner) code. ...
New

Most Active This Week Top

Most Active This Month Top

Margaret
Ask Me Anything with Mark Volkmann @mvolkmann On February 24 and 25, we are giving you a chance to ask questions of PragProg author M...
New

Most Active This Year Top

PragmaticBookshelf
Build modern server-driven web applications using htmx. Whatever programming language you use, you’ll write less (and cleaner) code. ...
New
jayhowey
@mvolkmann Hi Mark and Authors, In the new Beta 3.0 of the book, on page xiii, in the Foreword section by Carson Gross, in this third p...
New
ralfkret
On page 35 (chapter 3. Developing Endpoints) in the “Your Turn” section it says “In the endpoint, set HX-Target…”. Shouldn’t that be HX-T...
New

Most Active Last Three Years Top

Most Active Over Three Years Top

Get money off!

The Pragmatic Bookshelf

35% off any eBook

Simply use coupon code "devtalk.com" at checkout. See full details here.