コンテンツにスキップ

htmx

htmx で Hono を使用する方法。

typed-htmx

typed-htmx を使用することで、htmx 属性の TypeScript の定義を備えた JSX を記述できます。typed-htmx のサンプルプロジェクト にあるのと同じパターンに従って、hono/jsx で使用できます。

パッケージをインストールします

sh
npm i -D typed-htmx

src/global.d.ts (または HonoX を使用している場合、app/global.d.ts) で、typed-htmx の型をインポートします

ts
import 'typed-htmx'

typed-htmx の定義で Hono の JSX 型を拡張します

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 {}
  }
}

また、 を参照してください

MIT ライセンスに基づいてリリースされました。