Skip to content

HTM

JSX-free tagged template syntax that pairs naturally with Preact.

Native PreactActive

Native Preact

Built for Preact and does not require a React compatibility layer.

Packagehtm

Facts at a glance
Preact compatibility
Native Preact
Tested Preact versions
Not documented
TypeScript
Native TypeScript
SSR
SSR supported
Maintenance
Active
License
MIT
Last verified
Not yet verified
Terminal
npm install htm
Preact example
import { h } from "preact";import htm from "htm"; const html = htm.bind(h); export const App = () => html`<h1>Hello from HTM</h1>`;

Introduction

HTM is useful when you want Preact without a JSX transform, especially in embedded or low-tooling environments.

Preact configuration

Bind HTM to Preact's `h` function once and reuse it.

SSR notes

Works in server-rendered environments because it ultimately produces standard Preact VNodes.

Islands notes

Useful in very small islands where you want to avoid extra compile setup.

Alternatives