MCPcopy Index your code
hub / github.com/Desdaemon/typed-htmx

github.com/Desdaemon/typed-htmx @v0.3.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.3.1 ↗ · + Follow
28 symbols 47 edges 13 files 3 documented · 11%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

typed-htmx

npm docs tests

demo

Definitions for htmx attributes in JSX.

Usage

You can configure typed-htmx either as pure type declarations, or as a JSX templating engine.

As type declarations

Configure your tsconfig.json as follows:

{
  "compilerOptions": {
    "jsx": "react",
    "moduleResolution": "node16", // or "nodenext"
    "types": ["typed-htmx" /** and any other types you need */]
  }
}

An alternative is to include a triple-slash directive wherever you need completions for htmx attributes:

/// <reference types="typed-htmx" />

function MyComponent({ children }) {
  return 

{children}

;
  //          ^?: string | undefined
}

If your frontend library injects its own JSX types, you'll need to augment it. See the example project for a demo. typed-html and React are supported out of the box.

As a JSX templating engine

If you prefer to use JSX only for its templating capabilities in the vein of typed-html, you can use typed-htmx/typed-html which is included with this library and optimized for htmx usage:

  • Attributes such as hx-vals and hx-headers may also accept an object literal, which will be stringified on demand.
  • Configurable options for sanitization, defaults to a no-op.

Configure your tsconfig.json as follows:

{
  "compilerOptions": {
    "jsx": "react-jsx",
    "jsxImportSource": "typed-htmx/typed-html",
    "moduleResolution": "node16" // or "nodenext"
  }
}

Extension points exported contracts — how you extend this code

HtmxBuiltinExtensions (Interface)
* An extensible directory of htmx extensions. * * ### Declaring a new extension * * ```tsx twoslash * // in foo.d.t
src/jsx.d.ts
HTMLAttributes (Interface)
(no doc)
example/src/types.d.ts
JsxConfig (Interface)
(no doc)
src/index.ts
HtmxAttributes (Interface)
* Definitions for htmx attributes up to 1.9.10. * * ###### Path variables * `hx-get`, `hx-post` and other request at
src/jsx.d.ts
HTMLElement (Interface)
@ignore
src/jsx.d.ts
HtmxExtensions (Interface)
(no doc)
src/jsx.d.ts
HtmlTag (Interface)
(no doc)
src/jsx.d.ts

Core symbols most depended-on inside this repo

isRenderable
called by 3
src/index.ts
htmlSanitizer
called by 2
src/index.ts
isObject
called by 2
src/index.ts
sanitizer
called by 2
src/typed-html/jsx-runtime.ts
expandLiterals
called by 2
src/typed-html/jsx-runtime.ts
attrSanitizer
called by 1
src/index.ts
attrSanitizerWithoutDQ
called by 1
src/index.ts
toString
called by 1
src/typed-html/jsx-runtime.ts

Shape

Function 17
Interface 7
Class 2
Method 2

Languages

TypeScript100%

Modules by API surface

src/typed-html/jsx-runtime.ts9 symbols
src/index.ts8 symbols
src/jsx.d.ts5 symbols
docs/src/pages/index.js2 symbols
src/typed-html/jsx-dev-runtime.ts1 symbols
example/src/types.d.ts1 symbols
example/src/index.jsx1 symbols
docs/src/components/HomepageFeatures/index.js1 symbols

For agents

$ claude mcp add typed-htmx \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact