PHPackages                             putyourlightson/craft-htmx - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. putyourlightson/craft-htmx

Abandoned → [putyourlightson/craft-sprig](/?search=putyourlightson%2Fcraft-sprig)Craft-plugin[Utility &amp; Helpers](/categories/utility)

putyourlightson/craft-htmx
==========================

Provides helpers for integrating Htmx with Craft CMS.

v1.x-dev(2y ago)901mitPHP

Since Jun 6Pushed 2y ago2 watchersCompare

[ Source](https://github.com/putyourlightson/craft-htmx)[ Packagist](https://packagist.org/packages/putyourlightson/craft-htmx)[ RSS](/packages/putyourlightson-craft-htmx/feed)WikiDiscussions v1 Synced today

READMEChangelogDependencies (1)Versions (1)Used By (0)

[![](https://raw.githubusercontent.com/putyourlightson/craft-htmx/v1/src/icon.svg)](https://raw.githubusercontent.com/putyourlightson/craft-htmx/v1/src/icon.svg)

Htmx Plugin for Craft CMS 3
===========================

[](#htmx-plugin-for-craft-cms-3)

> This plugin is no longer maintained and has been replaced by [Sprig](https://putyourlightson.com/plugins/sprig).

Provides components and helpers for using [Htmx](https://htmx.org/) with [Craft CMS 3](https://craftcms.com/).

The plugin will automatically route any action requests made from Htmx through the `htmx/route` controller to ensure that the result is always in the format `text/html` and that no redirects take place.

Variables
---------

[](#variables)

The `craft.htmx` variable (and the shorthand version `hx`) is available in your twig templates. It provides components as well as values passed in through the [Htmx request headers](https://htmx.org/docs/#request-headers).

### `craft.htmx.component(template, options = {})`

[](#crafthtmxcomponenttemplate-options--)

Renders a reactive component using the provided template.

```
{{ hx.component('path/to/template', {
    params: {
        entryId: entry.id,
        title: entry.title,
    },
}) }}
```

The `params` automatically become available as twig variables in the component:

```
Entry ID: {{ entryId }}

{# Add `hx-get` to make the input field reactive #}

{{ title|length }} characters of max 255

{# Any `hx-` attributes can be used #}
Refresh
```

### `craft.htmx.get(tag, options = {})`

[](#crafthtmxgettag-options--)

Renders a `get` component using the provided tag and options.

```
{# Minimal example #}
{{ hx.get('div', {
    content: 'Like',
}) }}

{# Example with all possible options #}
{{ hx.get('button', {
    url: '/like',
    content: 'Like',
    params: {
        entryId: 1,
    },
    hx: {
        trigger: 'click',
    },
    attributes: {
        class: 'btn',
    }
}) }}
```

Which will be output as:

```
{# Minimal example #}
Like

{# Example with all possible options #}
Like
```

### `craft.htmx.post(tag, options = {})`

[](#crafthtmxposttag-options--)

Renders a `post` component using the provided tag and options. A CSRF token will automatically be added *if* CSRF validation is enabled.

```
{# Minimal example #}
{{ hx.post('form', {
    content: '',
}) }}

{# Example with all possible options #}
{{ hx.post('form', {
    url: '/like',
    content: '',
    params: {
        entryId: 1,
    },
    hx: {
        confirm: 'Are you sure?',
    },
    attributes: {
        class: 'form',
    }
}) }}
```

Which will be output as:

```
{# Minimal example #}

{# Example with all possible options #}

```

### `craft.htmx.script(attributes = {})`

[](#crafthtmxscriptattributes--)

Returns a script tag to include the latest version of Htmx from unpkg.com.

```

```

### `craft.htmx.request`

[](#crafthtmxrequest)

Returns `true` if this is a Htmx request, otherwise `false`.

### `craft.htmx.trigger.id`

[](#crafthtmxtriggerid)

Returns the ID of the element that triggered the request.

### `craft.htmx.trigger.name`

[](#crafthtmxtriggername)

Returns the name of the element that triggered the request.

### `craft.htmx.target.id`

[](#crafthtmxtargetid)

Returns the ID of the target element.

### `craft.htmx.url`

[](#crafthtmxurl)

Returns the URL of the browser.

### `craft.htmx.prompt`

[](#crafthtmxprompt)

Returns the value entered by the user when prompted via `hx-prompt`.

### `craft.htmx.eventTarget.id`

[](#crafthtmxeventtargetid)

Returns the ID of the original target of the event that triggered the request.

### `craft.htmx.element.id`

[](#crafthtmxelementid)

Returns the ID of the current active element.

### `craft.htmx.element.name`

[](#crafthtmxelementname)

Returns the name of the current active element.

### `craft.htmx.element.value`

[](#crafthtmxelementvalue)

Returns the value of the current active element.

Requirements
------------

[](#requirements)

Craft CMS 3.0.0 or later.

Installation
------------

[](#installation)

Install the plugin using composer.

```
composer require putyourlightson/craft-htmx:^0.1.0

```

License
-------

[](#license)

This plugin is licensed for free under the MIT License.

Created by [PutYourLightsOn](https://putyourlightson.com/).

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity28

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1068d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/59428c6783d02d74c8778d9953ba84c35d3877ece53f5eb393689c052a9c97e4?d=identicon)[putyourlightson](/maintainers/putyourlightson)

---

Top Contributors

[![bencroker](https://avatars.githubusercontent.com/u/57572400?v=4)](https://github.com/bencroker "bencroker (2 commits)")

### Embed Badge

![Health badge](/badges/putyourlightson-craft-htmx/health.svg)

```
[![Health](https://phpackages.com/badges/putyourlightson-craft-htmx/health.svg)](https://phpackages.com/packages/putyourlightson-craft-htmx)
```

###  Alternatives

[spicyweb/craft-neo

A Matrix-like field type with block hierarchy

395798.1k10](/packages/spicyweb-craft-neo)[verbb/navigation

Create navigation menus for your site.

90683.7k17](/packages/verbb-navigation)[verbb/formie

The most user-friendly forms plugin for Craft.

101372.9k40](/packages/verbb-formie)[solspace/craft-freeform

The most flexible and user-friendly form building plugin!

52664.9k12](/packages/solspace-craft-freeform)[verbb/comments

Add comments to your site.

13753.1k](/packages/verbb-comments)[craftcms/ckeditor

Edit rich text content in Craft CMS using CKEditor.

48359.1k52](/packages/craftcms-ckeditor)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
