Skip to content

esmiralha/express-htmx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

express-htmx

Extensions for using htmx with Express.

Installation

This is a Node.js module available through the npm registry. Installation is done using the npm install command:

npm i --save express-htmx

How to use

The htmx module contains two sub-modules:

  • middleware: an express-compatible middleware that populates the request with an htmx object that contains functions to deal with htmx custom headers
  • http: a simple API to add htmx custom headers to the response
const express = require("express");
const htmx = require("express-htmx");

const app = express();

app.use(htmx.middleware);

app.get("/", function (req, res) {
  if (req.isHtmx()) {
    // serve partial
  } else {
    // serve full page
  }
});

About

Extensions for using htmx with Express.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published