Ktor - HTMX

  • HTMX

    HTMX is a lightweight JavaScript library that enables dynamic client-side behavior using HTML attributes. It supports features such as AJAX, CSS transitions, WebSockets, and Server-Sent Events — without writing JavaScript.

    Ktor provides experimental, first-class support for HTMX through a set of shared modules that simplify integration in both server and client contexts. These modules offer tools for working with HTMX headers, defining HTML attributes using Kotlin DSLs, and handling HTMX-specific routing logic on the server.

    Ktor’s HTMX integration provides:

    • HTMX-aware routing for handling HTMX requests based on headers.
    • HTML DSL extensions to generate HTMX attributes in Kotlin.
    • HTMX header constants and values to eliminate string literals.

    Ktor’s HTMX support is available across three experimental modules:

    ModuleDescription
    ktor-htmxCore definitions and header constants
    ktor-htmx-htmlIntegration with the Kotlin HTML DSL
    ktor-server-htmxRouting support for HTMX-specific requests

    All APIs are marked with @ExperimentalKtorApi and require opt-in via @OptIn(ExperimentalKtorApi::class).

    For more information, see HTMX integration

    Pending