Hacker News new | ask | show | jobs
by domenicd 2769 days ago
HTM is React-compatible, and has all the React semantics: e.g. you can interpolate attributes (with ...${foo} instead of React's ...foo) and tag names (with <${foo}> instead of React's capitalization-dependent <Foo>).

In other words, HTM is a drop-in replacement for JSX that avoids the need for a compiler by using the corresponding language features. (At the cost of a few extra ${}s.)

lit-html and its ilk render directly to the DOM. They give similar developer ergonomics to React/JSX, but don't integrate with that ecosystem. They aren't a drop-in replacement for a JSX compiler within your React app; they're more of a competitor to the entire React paradigm.

Also of note is that, as a drop-in replacement, HTM is properties-first, like React/JSX. lit-html has you use different syntax for properties and for attributes.

Both are cool!

1 comments

I wouldn't describe it as a "drop-in replacement". It's very similar in the way that it allows one to use html syntax within javascript, and I appreciate the fact that it doesn't require and extra compilation step. But it does appear to be lacking what I see as the main draw of %eact -- the ability to compose and remix components. (Correct me if I'm wrong?)

Edit: Composability does appear to be a feature. I agree with your description.