HTMX

StreetJS + HTMX

Build interactive, server-rendered apps with typed StreetJS controllers that return HTML. HTMX swaps fragments into the DOM — no SPA, no client build step.

StreetJS stays frontend-agnostic: HTMX support lives in the optional @streetjs/plugin-htmx plugin, never in core. The plugin ships a dependency-free view engine (layouts + partials), HX-Request detection, HX-* response-header helpers, and CSRF form fields.

Why HTMX on StreetJS

  • One language, one stack — typed controllers render HTML; no separate SPA.
  • Server-rendered = SEO-friendly — crawlable HTML by default.
  • Smaller payloads — send HTML fragments, not a hydrating JS bundle.
  • Batteries already here — auth, sessions, CSRF, WebSockets and SSE come from core.

Quick start

1
2
npx @streetjs/cli create my-app --frontend htmx
cd my-app && npm install

This scaffolds a server-rendered app: src/views/{layouts,partials,pages}, a ViewsController, public/, and the @streetjs/plugin-htmx dependency. Wire the middleware (one time, see the generated HTMX.md):

1
2
3
4
5
import HtmxPlugin from '@streetjs/plugin-htmx';
import { ViewsController } from './controllers/views.controller.js';

app.use(HtmxPlugin.middleware({ viewsDir: 'src/views', layout: 'main' }));
app.registerController(ViewsController);

In this section

@streetjs/plugin-htmx is part of the StreetJS ecosystem roadmap. Track status in the plugin marketplace and the changelog.


Table of contents