Zum Inhalt springen

htmx ​

Hono zusammen mit htmx verwenden.

typed-htmx ​

Mit typed-htmx kannst du JSX mit TypeScript-Typdefinitionen für htmx-Attribute schreiben. Wir können dem Muster des typed-htmx-Beispielprojekts folgen, um es mit hono/jsx zu verwenden.

Installiere das Paket:

sh
npm i -D typed-htmx

Importiere die Typen von typed-htmx in src/global.d.ts (oder in app/global.d.ts, wenn du HonoX verwendest):

ts
import 'typed-htmx'

Erweitere Honos JSX-Typen um die Definitionen von typed-htmx:

ts
// A demo of how to augment foreign types with htmx attributes.
// In this case, Hono sources its types from its own namespace, so we do the same
// and directly extend its namespace.
declare module 'hono/jsx' {
  namespace JSX {
    interface HTMLAttributes extends HtmxAttributes {}
  }
}

Siehe auch ​

Veröffentlicht unter der MIT-Lizenz.