finds.dev← search

// the find

developit/htm

★ 9,045 · JavaScript · Apache-2.0 · updated Feb 2024

Hyperscript Tagged Markup: JSX alternative using standard tagged templates, with compiler support.

htm is a tiny tagged-template library that mimics JSX syntax without a build step, letting you write `html\`<div>${x}</div>\`` and bind it to any hyperscript-style function (Preact's h, React.createElement, vhtml, etc). It's aimed at people who want Preact/React-style component trees in plain JS — CodePen demos, no-bundler prototypes, small widgets embedded on someone else's page.

Genuinely tiny (under 600 bytes standalone, ~450 for the mini build) and the Preact standalone bundle is a real one-file drop-in with no npm install required. The framework-agnostic binding model (`htm.bind(h)`) is clean — it works with Preact, React, vhtml, or a plain object builder, so it's not locked to one rendering library. Template caching means repeated calls to the same tagged template return referentially stable output, which matters for diffing performance in Preact/React.

Last commit was Feb 2024 and it's a single-maintainer (developit) project — there's noticeable JSX-parity drift already (no TypeScript generics for props, spread syntax is `...${props}` instead of `{...props}`, self-closing custom syntax like `<//>` that no editor tooling other than the lit-html extension understands). Editor/tooling support is weak: without the specific VSCode lit-html extension or vim plugin, you get no syntax highlighting inside the template string, and TypeScript inference on children/props is much worse than JSX's. There's no source-map story for debugging — errors inside a template literal point at the whole tagged template, not a specific tag/attribute, which makes larger UIs painful to debug. It's really only load-bearing for people avoiding a build step entirely; anyone already running Babel/Vite gets nothing from htm over JSX except smaller output, and the escape hatch back to JSX (`babel-plugin-htm`) is a separate, thinly-maintained sub-package.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →