by simonbarker87 · 2y ago · 0 comments
I use htmx for as much of my network requests and UI updating as possible as it’s faster to implement features, faster the render and easier to reason around than a SPA front end and JSON response backend - there’s a chance the OP is in a similar boat.
The downside to a JS SSR driven app is the backend templating situation isn’t as expressive as JSX and can feel a bit limiting.
Hopefully OP will chime in and correct of confirm my assumptions.
I've been using it for small projects and I didn't want to be bothered with all of the setup required to get jsx/tsx transpilation in place.
Another important reason was that I wanted a tool that would let me reach high results in lighthouse, and that's not something you'd get with other tools quickly. Critical css out of the box seemed to be approach that worked for me in this scenario.
[0] I documented the compiler options and the reasoning behind them in if you expand the Explanations section of this Getting Started document: https://worldmaker.net/butterfloat/#/getting-started
[1] https://github.com/WorldMaker/butterfloat/blob/main/jsx.ts
[2] https://github.com/snabbdom/snabbdom/blob/master/src/jsx.ts
lib.dom.ts is one of the many lib files shipped with Typescript itself. I mention @types/react mostly as an example of probably what not to do, but it is a simple Node package maintained by DefinitelyTyped and easy to lookup if you did want to do things the brute force way (as many have, because it is easy to do). I also linked to two different examples of the type definition work, they are small files that are maybe not easy to follow in the way they used advanced concepts of Typescript's type system, but show that you can do a lot without copy and pasting thousands of lines from @types/react. You can replace most of the complex types in either file with `any` and get a quick and dirty minimalist type definition file. (If you go far enough back in the commit history of either the files I posted you can find examples of that, too.)
For what it is worth, I test Butterfloat with JSDOM entirely in Node (after Typescript building) and SSR/SSG/progressive enhancement and other backend support has always been on its roadmap, parts of it exist today and other parts were architected with it in mind, but it just hasn't yet been prioritized (because so far it is admittedly a solo project). I also wanted something that was simple to setup and use, backend or frontend, and would score well on lighthouse but also might score well in Web Components and also make sense replacing old Knockout.JS code from a decade or two ago.
Also, for some of us, no client side rendering is a feature not a deficiency.
I fully understand how to do everything the parent poster said, I just don’t want to do it and don’t think it’s the best dev experience in my use cases.