Another retro post! It’s 2025, and I’m writing about generating HTML server-side for web apps. After vast experience building SPAs, leading teams to build SPAs, hiring people and training people to build SPAs… it’s clear that SPAs are great for SPA-shaped problems, but are inherently more complex, unnecessarily so, for some other problems.
Hence, for a couple of experimental projects, I’m looking to generate HTML in TypeScript. Speed matters, specifically development speed, So I want an HTML aware typed mechanism, a generic plain text templating system. Here are some of the contenders I found with a few thoughts on each.
KitaJS
This library enables use of TSX on the server with reasonably good typing. It appears to be under ongoing development and in actual use. TSX/JSX is not my favorite syntax, but it is sufficiently good for the problem at hand and readily understandable by many developers and tools. (KitaJS is included in the box in ElysiaJS, by the way.)
Probably the strongest contender.
Thing-Hiccup and Hiccup-html
I somehow made it to March 2025 before being aware of https://thi.ng/ – an incredible mountain of code created primarily by a prolific genius, full of ideas that are like catnip to me.
Thing’s hiccup for TypeScript is a re-implementation of the hiccup package from Clojure. There is an add-on package which has additional HTML-specific type support in the form of factory functions.
The Hiccup data structure style is not quite as approachable as TSX, but it is more concise, which is quite valuable.
This is another strong contender for anyone willing to have their HTML template not look like HTML.
Typed-html
Promising but appears to be abandoned.
bun-tsx-html
This appears to be just an example or a template; I don’t get the impression it’s under any production use anywhere. But it has an interesting approach: Preact-based TSX, then executed on the server to produce HTML – at least if I understood it right.
tsx-dom-ssr
This is one of a collection of TSX/DOM libraries, which can be used for server-side HTML generation. More complete and well-developed than the above, but I’m not completely sure whether it is suited for the purpose I have at hand. I’ll keep an eye on this one, though.
Generic template tools
My search for tools to emit HTML and TypeScript was derailed by an enormous number of generic non-HTML-specific templating tools out there; omitted from this list.
An honorable mention goes to pug.js, which understands HTML, but does not have TypeScript types. I’m slightly sentimental for pug, having used it around 2012-2013 on large AngularJS projects.