HTMX + TypeScript Backend: Building Server-Rendered Apps with StreetJS #3860
hassanmubiru
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I've been experimenting with HTMX on top of a TypeScript backend framework called StreetJS and wanted to share the approach and get feedback from the HTMX community.
One thing I noticed is that most HTMX examples in the TypeScript ecosystem tend to use Express, Fastify, or custom setups. We wanted to see what a more integrated HTMX experience would look like while keeping the backend responsible for rendering HTML.
What we built
StreetJS now has:
HTMX plugin support
Server-rendered views
Layouts and partials
CSRF integration
Session-based authentication
WebSocket and SSE support
HTMX response helpers
HTMX starter project
Example:
return ctx.view('dashboard', { user });
The same controller can return a full page for normal requests and a fragment for HTMX requests.
if (ctx.hx.isHtmx) {
return ctx.partial('users/list', { users });
}
return ctx.view('users', { users });
HTMX response helpers:
ctx.hx.redirect('/dashboard');
ctx.hx.trigger('userCreated', {
id: user.id
});
Why we explored this
A lot of business applications are:
SaaS dashboards
Internal tools
Admin panels
CRUD systems
Customer portals
For these applications, HTMX feels like a natural fit because the server remains the source of truth and HTML becomes the transport format.
Instead of maintaining:
API routes
Client state
Data fetching layers
Hydration logic
the application simply renders HTML from the backend.
Realtime
StreetJS already includes WebSocket support, so we experimented with sending rendered HTML fragments over WebSockets instead of JSON.
Example:
The server broadcasts rendered HTML fragments that HTMX swaps directly into the page.
Question for the community
For those building larger HTMX applications:
How are you organizing templates and partials?
Are you using WebSockets, SSE, or polling most often?
What patterns have worked well for authentication and multi-tenant SaaS apps?
What do you consider essential for a backend framework to provide when targeting HTMX?
I'd love feedback from people who have deployed HTMX in production.
StreetJS project:
https://github.com/hassanmubiru/StreetJS
HTMX docs section:

https://hassanmubiru.github.io/StreetJS/htmx/
https://www.npmjs.com/package/@streetjs/plugin-htmx
Beta Was this translation helpful? Give feedback.
All reactions