{"id":36965104,"url":"https://github.com/srdjan/hsx","last_synced_at":"2026-02-16T00:23:05.576Z","repository":{"id":327309705,"uuid":"1108784986","full_name":"srdjan/hsx","owner":"srdjan","description":"SSR-only JSX/TSX renderer for Deno that hides HTMX away :)","archived":false,"fork":false,"pushed_at":"2025-12-28T21:53:02.000Z","size":288,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-11T14:04:40.188Z","etag":null,"topics":["deno","htmx","ssr","typescript","ui"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/srdjan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-02T23:09:57.000Z","updated_at":"2025-12-28T21:53:05.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/srdjan/hsx","commit_stats":null,"previous_names":["srdjan/gotium.jsx"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/srdjan/hsx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srdjan%2Fhsx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srdjan%2Fhsx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srdjan%2Fhsx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srdjan%2Fhsx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/srdjan","download_url":"https://codeload.github.com/srdjan/hsx/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srdjan%2Fhsx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28398090,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deno","htmx","ssr","typescript","ui"],"created_at":"2026-01-13T19:52:37.234Z","updated_at":"2026-02-16T00:23:05.541Z","avatar_url":"https://github.com/srdjan.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HSX is love, HSX is life\n\nFirst things, first... What the hack does HSX stand for? I'll say it's '**H**TML\nfor **S**erver-Side e**X**tensions'. :0\n\nBut, honestly, I prefer: **H**TMX **S**laps **X**tremely :)\n\nSSR-only JSX/TSX renderer for Deno that hides HTMX-style attributes away during the rendering process, and compiles them to `hx-*` attributes.\n\n\u003e Disclaimer: this was a quick hack in my free time, held together by vibe\n\u003e coding and espresso. I like it a lot, but consider it an early release. I feel it is getting better (a lot)\n\n## TL;DR: Like JSX, but for SSR HTML + HTMX.\n\n## Features\n\n- **SSR-only** - No client runtime. Outputs plain HTML.\n- **HTMX as HTML** - Write `get`, `post`, `target`, `swap` as native attributes\n- **Type-safe routes** - Branded `Route\u003cPath\u003e` types with automatic parameter\n  inference\n- **Co-located components** - `hsxComponent()` bundles route + handler + render\n- **Page guardrails** - `hsxPage()` enforces semantic, style-free layouts\n- **Branded IDs** - `id(\"name\")` returns `Id\u003c\"name\"\u003e` typed as `\"#name\"`\n- **Auto HTMX injection** - `\u003cscript src=\"/static/htmx.js\"\u003e` injected when\n  needed\n- **No manual hx-\\*** - Throws at render time if you write `hx-get` directly\n- **Widgets** - Define once, serve via SSR or embed as iframes with\n  Declarative Shadow DOM\n\n## Installation\n\n### From JSR\n\n```bash\ndeno add jsr:@srdjan/hsx\n```\n\nOr import directly:\n\n```ts\nimport { id, render, route } from \"jsr:@srdjan/hsx\";\n```\n\n### Separate Packages\n\nHSX is a monorepo with three packages:\n\n```ts\n// Core - JSX rendering, type-safe routes, hsxComponent, hsxPage\nimport { Fragment, hsxComponent, hsxPage, id, render, route } from \"jsr:@srdjan/hsx\";\n\n// Styles - ready-to-use CSS with theming support\nimport { HSX_STYLES_PATH, hsxStyles } from \"jsr:@srdjan/hsx-styles\";\n\n// Widgets - embeddable widget protocol + SSR/embed adapters\nimport { widgetToHsxComponent } from \"jsr:@srdjan/hsx-widgets/ssr\";\n```\n\nInstall individually:\n\n```bash\ndeno add jsr:@srdjan/hsx\ndeno add jsr:@srdjan/hsx-styles\ndeno add jsr:@srdjan/hsx-widgets\n```\n\n### Selective Imports (Tree-Shaking)\n\nFor smaller bundles, import only what you need:\n\n```ts\n// Core only - render, route, id, Fragment (smaller bundle)\nimport { render, route, id, Fragment } from \"jsr:@srdjan/hsx/core\";\n\n// Components only - hsxComponent, hsxPage\nimport { hsxComponent, hsxPage } from \"jsr:@srdjan/hsx/components\";\n\n// Everything (default)\nimport { render, route, hsxComponent, hsxPage } from \"jsr:@srdjan/hsx\";\n```\n\n### From Source\n\nClone and import using workspace package names:\n\n```ts\nimport { hsxComponent, hsxPage, id, render, route } from \"@srdjan/hsx\";\n```\n\n## Quick Start (Low-Level API)\n\n\u003e **Note:** This shows the low-level API using `route()`. For most projects, use\n\u003e the [hsxComponent pattern](#hsx-component-pattern-recommended) below instead.\n\n```tsx\nimport { id, render, route } from \"@srdjan/hsx\";\n\nconst routes = {\n  todos: route(\"/todos\", () =\u003e \"/todos\"),\n};\n\nconst ids = {\n  list: id(\"todo-list\"),\n};\n\nfunction Page() {\n  return (\n    \u003chtml\u003e\n      \u003chead\u003e\n        \u003ctitle\u003eHSX Demo\u003c/title\u003e\n      \u003c/head\u003e\n      \u003cbody\u003e\n        \u003cform post={routes.todos} target={ids.list} swap=\"outerHTML\"\u003e\n          \u003cinput name=\"text\" required /\u003e\n          \u003cbutton type=\"submit\"\u003eAdd\u003c/button\u003e\n        \u003c/form\u003e\n        \u003cul id=\"todo-list\"\u003e{/* items */}\u003c/ul\u003e\n      \u003c/body\u003e\n    \u003c/html\u003e\n  );\n}\n\nDeno.serve(() =\u003e render(\u003cPage /\u003e));\n```\n\n**Output HTML:**\n\n```html\n\u003chtml\u003e\n  \u003chead\u003e\u003ctitle\u003eHSX Demo\u003c/title\u003e\u003c/head\u003e\n  \u003cbody\u003e\n    \u003cform hx-post=\"/todos\" hx-target=\"#todo-list\" hx-swap=\"outerHTML\"\u003e\n      \u003cinput name=\"text\" required\u003e\n      \u003cbutton type=\"submit\"\u003eAdd\u003c/button\u003e\n    \u003c/form\u003e\n    \u003cul id=\"todo-list\"\u003e\u003c/ul\u003e\n    \u003cscript src=\"/static/htmx.js\"\u003e\u003c/script\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n## HSX Component Pattern (Recommended)\n\n```ts\nimport { hsxComponent } from \"jsr:@srdjan/hsx\";\n\nexport const TodoList = hsxComponent(\"/todos\", {\n  methods: [\"GET\", \"POST\"],\n\n  async handler(req) {\n    if (req.method === \"POST\") {\n      const form = await req.formData();\n      await addTodo(String(form.get(\"text\")));\n    }\n    return { todos: await getTodos() }; // must match render props\n  },\n\n  render({ todos }) {\n    return (\n      \u003cul id=\"todo-list\"\u003e\n        {todos.map((t) =\u003e \u003cli key={t.id}\u003e{t.text}\u003c/li\u003e)}\n      \u003c/ul\u003e\n    );\n  },\n});\n\n// Use as route in JSX\n\u003cform post={TodoList} target=\"#todo-list\" swap=\"outerHTML\" /\u003e;\n\n// Use as handler in your server\nif (TodoList.match(url.pathname)) return TodoList.handle(req);\n```\n\nTypeScript enforces that `handler` returns the same shape that `render` expects.\n`methods` defaults to `[\"GET\"]`; set `fullPage: true` when your render function\nreturns a full document instead of a fragment.\n\n\u003e **Choose one style:** Use either `hsxComponent` (recommended) or the low-level\n\u003e `route()` API, but don't mix them in the same project.\n\n## hsxPage (full-page guardrails)\n\n`hsxPage()` wraps a render function that returns a **complete** HTML document\nand validates that:\n\n- The root is `\u003chtml\u003e` with `\u003chead\u003e` then `\u003cbody\u003e`\n- Semantic tags (header/main/section/article/h1-h6/p/ul/ol/li/etc.) have **no**\n  `class` or inline `style`\n- `\u003cstyle\u003e` tags live in `\u003chead\u003e`; CSS belongs there, not inline\n- Composition stays within semantic HTML + HSX components\n\n```tsx\nimport { hsxComponent, hsxPage } from \"jsr:@srdjan/hsx\";\n\nconst Widget = hsxComponent(\"/data\", {\n  handler: () =\u003e ({ message: \"Hi\" }),\n  render: ({ message }) =\u003e \u003cp\u003e{message}\u003c/p\u003e,\n});\n\nconst Page = hsxPage(() =\u003e (\n  \u003chtml lang=\"en\"\u003e\n    \u003chead\u003e\n      \u003ctitle\u003eGuarded Page\u003c/title\u003e\n      \u003cstyle\u003e{\"body { font-family: system-ui; }\"}\u003c/style\u003e\n    \u003c/head\u003e\n    \u003cbody\u003e\n      \u003cheader\u003e\n        \u003ch1\u003eWelcome\u003c/h1\u003e\n      \u003c/header\u003e\n      \u003cmain\u003e\n        \u003csection\u003e\n          \u003cdiv class=\"card\"\u003e\n            \u003cWidget.Component /\u003e\n          \u003c/div\u003e\n        \u003c/section\u003e\n      \u003c/main\u003e\n    \u003c/body\u003e\n  \u003c/html\u003e\n));\n\nDeno.serve(() =\u003e Page.render());\n```\n\n## HSX Attributes\n\n| HSX Attribute      | Renders To        | Description                    |\n| ------------------ | ----------------- | ------------------------------ |\n| `get`              | `hx-get`          | HTTP GET request               |\n| `post`             | `hx-post`         | HTTP POST request              |\n| `put`              | `hx-put`          | HTTP PUT request               |\n| `patch`            | `hx-patch`        | HTTP PATCH request             |\n| `delete`           | `hx-delete`       | HTTP DELETE request            |\n| `target`           | `hx-target`       | Element to update              |\n| `swap`             | `hx-swap`         | How to swap content            |\n| `trigger`          | `hx-trigger`      | Event that triggers request    |\n| `vals`             | `hx-vals`         | Additional values (JSON)       |\n| `headers`          | `hx-headers`      | Custom headers (JSON)          |\n| `behavior=\"boost\"` | `hx-boost=\"true\"` | Enable boost mode (`\u003ca\u003e` only) |\n\n**Supported elements:** `form`, `button`, `a`, `div`, `span`, `section`,\n`article`, `ul`, `tbody`, `tr`\n\n## Type-Safe Routes\n\nUse `route()` to create type-safe routes with automatic parameter extraction:\n\n```tsx\nconst routes = {\n  users: {\n    list: route(\"/users\", () =\u003e \"/users\"),\n    detail: route(\"/users/:id\", (p) =\u003e `/users/${p.id}`),\n    posts: route(\n      \"/users/:userId/posts/:postId\",\n      (p) =\u003e `/users/${p.userId}/posts/${p.postId}`,\n    ),\n  },\n};\n\n// In JSX - params are type-checked:\n\u003cbutton get={routes.users.detail} params={{ id: 42 }}\u003eView\u003c/button\u003e;\n// Renders: \u003cbutton hx-get=\"/users/42\"\u003eView\u003c/button\u003e\n```\n\n## Branded IDs\n\nUse `id()` to create type-safe element references:\n\n```tsx\nconst ids = {\n  list: id(\"todo-list\"),    // Type: Id\u003c\"todo-list\"\u003e = \"#todo-list\"\n  count: id(\"item-count\"),\n};\n\n// In JSX:\n\u003cul id=\"todo-list\"\u003e...\u003c/ul\u003e\n\u003cbutton get=\"/todos\" target={ids.list} swap=\"innerHTML\"\u003eRefresh\u003c/button\u003e\n// Renders: \u003cbutton hx-get=\"/todos\" hx-target=\"#todo-list\" hx-swap=\"innerHTML\"\u003e\n```\n\n## Wrapper Components\n\nCreate reusable wrapper components that pass through HSX attributes for cleaner\nJSX:\n\n```tsx\nimport type { HsxSwap, Urlish } from \"jsr:@srdjan/hsx\";\n\nfunction Card(props: {\n  children: unknown;\n  title?: string;\n  get?: Urlish;\n  trigger?: string;\n  swap?: HsxSwap;\n}) {\n  return (\n    \u003cdiv class=\"card\" get={props.get} trigger={props.trigger} swap={props.swap}\u003e\n      {props.title \u0026\u0026 \u003ch2\u003e{props.title}\u003c/h2\u003e}\n      {props.children}\n    \u003c/div\u003e\n  );\n}\n\nfunction Subtitle(props: { children: string }) {\n  return \u003cp class=\"subtitle\"\u003e{props.children}\u003c/p\u003e;\n}\n```\n\n**Usage:**\n\n```tsx\nfunction Page() {\n  return (\n    \u003cmain\u003e\n      \u003ch1\u003eDashboard\u003c/h1\u003e\n      \u003cSubtitle\u003eContent loads lazily\u003c/Subtitle\u003e\n      \u003cCard\n        get={routes.stats}\n        trigger=\"load\"\n        swap=\"innerHTML\"\n        title=\"Statistics\"\n      \u003e\n        \u003cLoadingSkeleton /\u003e\n      \u003c/Card\u003e\n      \u003cCard title=\"Team Members\"\u003e\n        \u003cUserList /\u003e\n      \u003c/Card\u003e\n    \u003c/main\u003e\n  );\n}\n```\n\nThis pattern keeps your page components clean while maintaining full access to\nHSX attributes. See the `examples/*/components.tsx` files for more examples.\n\n## Configuration\n\nAdd this to your `deno.json`:\n\n```jsonc\n{\n  \"imports\": {\n    \"hsx/jsx-runtime\": \"jsr:@srdjan/hsx/jsx-runtime\"\n  },\n  \"compilerOptions\": {\n    \"jsx\": \"react-jsx\",\n    \"jsxImportSource\": \"hsx\"\n  }\n}\n```\n\nJSX intrinsic element types (`\u003cdiv\u003e`, `\u003cform\u003e`, `\u003cbutton\u003e`, etc.) are\nautomatically included via the jsx-runtime import—no additional type\nconfiguration needed.\n\n### Serving HTMX\n\nHSX injects `\u003cscript src=\"/static/htmx.js\"\u003e` when HTMX is used. You must serve\nit:\n\n```ts\nif (url.pathname === \"/static/htmx.js\") {\n  const js = await Deno.readTextFile(\"./vendor/htmx/htmx.js\");\n  return new Response(js, {\n    headers: { \"content-type\": \"text/javascript; charset=utf-8\" },\n  });\n}\n```\n\n### Optional Styles Module\n\nHSX includes an optional CSS module with a default theme and dark variant:\n\n```ts\nimport {\n  HSX_STYLES_PATH,\n  hsxStyles,\n  hsxStylesDark,\n} from \"jsr:@srdjan/hsx-styles\";\n\n// Serve the styles\nif (url.pathname === HSX_STYLES_PATH) {\n  return new Response(hsxStyles, {\n    headers: { \"content-type\": \"text/css; charset=utf-8\" },\n  });\n}\n\n// In your page head\n\u003clink rel=\"stylesheet\" href={HSX_STYLES_PATH} /\u003e;\n```\n\n**Exports:**\n\n- `hsxStyles` - Default light theme (indigo accent)\n- `hsxStylesDark` - Dark theme variant\n- `HSX_STYLES_PATH` - Default path: `/static/hsx.css`\n\n**What you get (Fizzy-inspired defaults):**\n\n- Layout helpers: `container`, `stack`, `cluster`, `sidebar`, `split`, `auto-grid`, `hero`, `bleed`, `measure`\n- Components: `card`, `surface`, `callout.{info|success|warning|danger}`, `badge`, `pill`, `chip`, `divider`, `list-inline`, button sizes (`btn-sm`, `btn-lg`) and variants (`btn-ghost`, `btn-outline`)\n- Utilities: text sizes (`text-xs` … `text-3xl`), spacing (`p-sm`, `px-md`, `space-y-md`), flex/grid helpers (`flex`, `cols-2/3`, `gap-sm`), shadows/rounding (`shadow-sm`, `rounded-lg`), visibility (`visually-hidden`, `hidden`)\n\n**Customization:** Override CSS variables in your page:\n\n```tsx\n\u003cstyle\u003e{`:root { --hsx-accent: #10b981; --hsx-bg: #f0fdf4; }`}\u003c/style\u003e;\n```\n\nAvailable variables: `--hsx-accent`, `--hsx-accent-hover`, `--hsx-bg`,\n`--hsx-surface`, `--hsx-border`, `--hsx-text`, `--hsx-muted`, `--hsx-error`,\n`--hsx-success`, `--hsx-info`, `--hsx-warning`, `--hsx-neutral`, spacing\n(`--hsx-space-2xs` … `--hsx-space-3xl`), radius (`--hsx-radius-*`), typography\n(`--hsx-font-size-*`, `--hsx-leading-*`), shadows (`--hsx-shadow-*`),\nbreakpoints (`--hsx-breakpoint-sm|md|lg`), and layout tokens\n(`--hsx-container-max`, `--hsx-container-padding`, `--hsx-measure`).\n\n## HSX Widgets\n\nThe `@srdjan/hsx-widgets` package provides a widget protocol for building\ncomponents that work in two contexts: SSR through HSX routes, and embeddable\niframe shells for third-party pages.\n\n### Define a Widget\n\nA widget is a typed record with validation, styles, rendering, and optional\ndata loading:\n\n```tsx\nimport type { Widget } from \"jsr:@srdjan/hsx-widgets\";\nimport { ok, fail } from \"jsr:@srdjan/hsx-widgets\";\n\nexport const greetingWidget: Widget\u003cGreetingProps\u003e = {\n  tag: \"hsx-greeting\",\n  props: { validate(raw) { /* ... */ } },\n  styles: `.hsx-greeting { padding: 1rem; }`,\n  render: (props) =\u003e \u003cdiv class=\"hsx-greeting\"\u003e\u003ch2\u003e{props.name}\u003c/h2\u003e\u003c/div\u003e,\n  load: async (params) =\u003e ok({ name: params.name, message: `Hello!` }),\n  shadow: \"open\",  // Optional: Declarative Shadow DOM\n};\n```\n\n### Serve via SSR\n\nUse `widgetToHsxComponent()` to bridge a widget into an HSX route:\n\n```tsx\nimport { widgetToHsxComponent } from \"jsr:@srdjan/hsx-widgets/ssr\";\n\nconst GreetingRoute = widgetToHsxComponent(greetingWidget, {\n  path: \"/widgets/greeting/:name\",\n});\n\nif (GreetingRoute.match(url.pathname)) return GreetingRoute.handle(req);\n```\n\n### Embed on Third-Party Pages\n\nServe iframe shells with `createEmbedHandler()`, then embed with a snippet:\n\n```html\n\u003cdiv data-hsx-uri=\"https://yoursite.com/embed/hsx-greeting?name=World\"\u003e\u003c/div\u003e\n\u003cscript src=\"https://yoursite.com/static/hsx/snippet.js\"\u003e\u003c/script\u003e\n```\n\nSee [docs/WIDGETS.md](docs/WIDGETS.md) for the full widget guide including\nDeclarative Shadow DOM, style hoisting, and the build pipeline.\n\n## API Reference\n\n### `render(node, options?)`\n\nRenders JSX to an HTTP `Response`.\n\n```ts\nrender(\u003cPage /\u003e, {\n  status: 200, // HTTP status code\n  headers: {}, // Additional response headers\n  maxDepth: 100, // Max nesting depth (DoS protection)\n  maxNodes: 50000, // Max node count (DoS protection)\n  injectHtmx: undefined, // true/false to force, undefined for auto\n});\n```\n\n### `renderHtml(node, options?)`\n\nRenders JSX to an HTML string.\n\n```ts\nconst html = renderHtml(\u003cPage /\u003e, {\n  maxDepth: 100,\n  maxNodes: 50000,\n  injectHtmx: undefined,\n});\n```\n\n### `route(path, build)`\n\nCreates a type-safe route. Path parameters (`:param`) are automatically\nextracted.\n\n```ts\nconst r = route(\"/users/:id\", (p) =\u003e `/users/${p.id}`);\n// r.path = \"/users/:id\"\n// r.build({ id: 42 }) = \"/users/42\"\n```\n\n### `id(name)`\n\nCreates a branded element ID with `#` prefix.\n\n```ts\nconst listId = id(\"todo-list\");\n// Type: Id\u003c\"todo-list\"\u003e\n// Value: \"#todo-list\"\n```\n\n### `Fragment`\n\nJSX Fragment for grouping elements without a wrapper.\n\n```tsx\n\u003cFragment\u003e\n  \u003cli\u003eOne\u003c/li\u003e\n  \u003cli\u003eTwo\u003c/li\u003e\n\u003c/Fragment\u003e;\n```\n\n### `hsxComponent(path, options)`\n\nCo-locates a route, request handler, and render function.\n\n```ts\nconst Comp = hsxComponent(\"/items/:id\", {\n  methods: [\"GET\", \"DELETE\"], // defaults to [\"GET\"]\n  fullPage: false, // default: return fragment Response\n  status: 200,\n  headers: { \"x-powered-by\": \"hsx\" },\n  handler: async (_req, params) =\u003e ({\n    item: await getItem(params.id),\n  }),\n  render: ({ item }) =\u003e \u003cdiv\u003e{item.name}\u003c/div\u003e,\n});\n\n// Works anywhere a Route does:\n\u003cbutton delete={Comp} params={{ id: 42 }} target=\"#row-42\" /\u003e;\n```\n\n## Examples\n\nRun examples with `deno task`:\n\n| Example               | Command                             | Description                                           |\n| --------------------- | ----------------------------------- | ----------------------------------------------------- |\n| **Todos**             | `deno task example:todos`           | Full CRUD with partial updates                        |\n| **Active Search**     | `deno task example:active-search`   | Live search as you type                               |\n| **Lazy Loading**      | `deno task example:lazy-loading`    | Deferred content loading                              |\n| **Form Validation**   | `deno task example:form-validation` | Server-side validation                                |\n| **Polling**           | `deno task example:polling`         | Live dashboard with intervals                         |\n| **Tabs \u0026 Modal**      | `deno task example:tabs-modal`      | Tab navigation and modals                             |\n| **HSX Components**    | `deno task example:hsx-components`  | Co-located route + handler + render                   |\n| **HSX Page**          | `deno task example:hsx-page`        | Semantic full-page with hsxPage guardrails            |\n| **Low-Level API**     | `deno task example:low-level-api`   | Manual render/renderHtml without hsxPage/hsxComponent |\n| **HSX Widget**       | `deno task example:hsx-widget`     | Widget SSR route + iframe embed shell                 |\n| **Index of examples** | `examples/README.md`                | Quick guide to pick the right example                 |\n\nFor the HSX widget example, build client assets first:\n\n```bash\ndeno task build:hsx-widgets\ndeno task example:hsx-widget\n```\n\n## Safety\n\n- **HTML escaping** - All text content and attributes are escaped (XSS\n  prevention)\n- **Raw text elements** - `\u003cscript\u003e` and `\u003cstyle\u003e` children are NOT escaped.\n  Never pass user input.\n- **No manual hx-\\*** - Throws at render time. Use HSX aliases instead.\n- **DoS protection** - Optional `maxDepth` and `maxNodes` limits\n\n## Project Structure\n\n```\npackages/\n  hsx/                   # Core package (@srdjan/hsx)\n    mod.ts               # Main entry point\n    jsx-runtime.ts       # Minimal JSX runtime (compiler requirement)\n    render.ts            # SSR renderer with HTMX injection\n    hsx-normalize.ts     # HSX to hx-* attribute mapping\n    hsx-types.ts         # Route, Id, HsxSwap, HsxTrigger types\n    hsx-jsx.d.ts         # JSX type declarations\n    hsx-component.ts     # hsxComponent factory (route + handler + render)\n    hsx-page.ts          # hsxPage guardrail for full-page layouts\n  hsx-styles/            # Styles package (@srdjan/hsx-styles)\n    mod.ts               # Main entry point (CSS themes)\n  hsx-widgets/          # HSX widgets package (@srdjan/hsx-widgets)\n    mod.ts               # Main entry point\n    widget.ts            # Widget protocol\n    ssr-adapter.ts       # Widget -\u003e hsxComponent bridge (with Declarative Shadow DOM)\n    styles.ts            # Style collection for hsxPage\n    result.ts            # Result\u003cT,E\u003e type utilities\n    embed/               # Embed helpers (iframe shell + snippet)\n    build/               # Dual-compile build pipeline (esbuild + Preact)\nexamples/\n  todos/                 # Full todo app example\n  active-search/         # Search example\n  lazy-loading/          # Lazy load example\n  form-validation/       # Form validation example\n  polling/               # Polling example\n  tabs-modal/            # Tabs and modal example\n  hsx-components/        # HSX Component pattern example\n  hsx-page/              # hsxPage full-page guardrail example\n  low-level-api/         # Manual render/renderHtml without hsxPage/hsxComponent\n  hsx-widget/           # HSX widget SSR + embed shell example\nvendor/htmx/\n  htmx.js                # Vendored HTMX v4 (alpha)\ndocs/\n  EXAMPLES.md            # Full examples matrix\n  USER_GUIDE.md          # Comprehensive user guide\n  HSX_OVERVIEW.md        # Architecture overview\n  HTMX_INTEGRATION.md    # HTMX integration details\n  WIDGETS.md             # HSX widget guide and embed workflow\n```\n\n## License\n\nMIT - see [LICENSE](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsrdjan%2Fhsx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsrdjan%2Fhsx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsrdjan%2Fhsx/lists"}