Guides

Routing

app/pages/<route>/<route>.htmx is the template. An optional <route>.tsx next to it exports handlers per HTTP method.

import { page, get, post } from "@/routing/pageroute";

export default page([
  get(async () => ({ title: "Hello" })),
  post(async ({ body }) => <p>Got {body.name}</p>),
]);

Layouts

app/pages/layout.htmx wraps every page's <hx-content/> slot. app/pages/index.htmx is the outer HTML shell, wrapping <hx-root/>.

Interactivity with htmx

Add hx-post, hx-target and hx-swap to any element — htmx.js is already loaded on every page.