Uniform::HTMX::Mojolicious

CPAN version License: MIT

Framework-agnostic htmx adapter for the Mojolicious ecosystem.

Uniform::HTMX::Mojolicious inherits directly from Uniform::HTMX to bridge Mojolicious controllers with htmx request inspection and response manipulation methods.

Installation

Install using cpanm or your preferred CPAN client:

cpanm Uniform::HTMX::Mojolicious

Synopsis

use Mojolicious::Lite;
use Uniform::HTMX::Mojolicious;

get '/time' => sub {
    my $c    = shift;
    my $htmx = Uniform::HTMX::Mojolicious->new($c);

    if ($htmx->is_htmx) {
        $htmx->res_reswap('innerHTML')
             ->res_trigger('timeUpdated', { time => scalar localtime });

        $htmx->apply($c);
        return $c->render(text => '<div>Time updated!</div>');
    }

    $c->render(text => 'Standard request');
};

app->start;

Key Features

Local Development & Testing

Run the test suite using prove:

prove -Ilib t/

Run the live example application using morbo:

morbo examples/app.pl

This software is Copyright (c) 2026 by Joshua S. Day <HAX@cpan.org>.

This is free software, licensed under:

The MIT (X11) License