HBForge/Examples
17 · Integrations

htmx — HTML-over-the-wire partials

Server-rendered HTML, no client framework, no build step. The html`` tagged template auto-escapes; htmx swaps the partial in place.

forge/serverNodeBunDenoCF Workers
Code
htmx.js
const { WebApp, html } = require(class="tk-str">'@hyperbridge/forge/server');
const app = new WebApp();
let count = 0;

const button = (n) => htmlclass="tk-str">`
  <button hx-post="/click" hx-swap="outerHTML">
    Clicked ${n} times
  </button>
`;

app.get(class="tk-str">&#39;/&#39;, (c) => c.html(htmlclass="tk-str">`
  ${button(count)}
  <script src="https:class="tk-cm">//unpkg.com/htmx.org"></script>
`));

app.post(class="tk-str">&#39;/click&#39;, (c) => {
  count++;
  return c.html(button(count));
});

app.listen(3000);
How it works

htmx fetches HTML fragments and swaps them into the DOM. Combined with WebApp's html`` template, the server is the whole app.

No JSON, no client state, no rehydration mismatch. The page is the source of truth.

For a richer interactive layer, swap to forge/client — same module, same package.

Try it
Quickstart
open http://localhost:3000 → click the button
Related modules