npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@triptease/html-jsx

v0.2.6

Published

JSX implementation for generating static HTML

Readme

html-jsx: Typed HTML templates using JSX

Generate static HTML from JSX/TSX templates. The perfect solution to server side rendering of HTML, more performant than template engines with type checking for HTML.

Why use html-jsx?

  • Faster than traditional template engines since most of the work is done by the TypeScript compiler.
  • Type checking for HTML using type definitions generated from the WHATWG Living Standard.
  • It's secure. Escaping of tag contents and attributes to avoid XSS attacks.
  • Validation of HTML structure using WHATWG content categories.

Getting started

Add the package as a dev dependency

npm add -D @triptease/html-jsx

Add the JSX configuration into the compiler options in tsconfig.json

{
  "compilerOptions": {
    "jsx": "react-jsx",
    "jsxImportSource": "@triptease/html-jsx"
  }
}

Write your templates using JSX/TSX, no imports required.

function greet(name: string) {
  return (
    <div>
      <p>
        Hello ${name}
      </p>
    </div>
  );
}

Features

HTML Type safety

Invalid HTML elements are caught at compile time

<h7></h7>

// TS2339: Property h7 does not exist on type JSX.IntrinsicElements

Invalid HTML attributes are caught at compile time

<div classs="my-class"></div>

// TS2322: Type { classs: string; } is not assignable to type HtmlTagDiv
// Property 'classs' does not exist on type HtmlTagDiv. Did you mean 'class'?

HTML attributes are type-checked

<input required="falsey"></input>

// TS2820: Type 'falsey' is not assignable to type BooleanAttribute | undefined. Did you mean 'false'?

Structural HTML validation

Validation of HTML structure using the WHATWG content categories is applied at runtime when NODE_ENV is set to development.

<span>
  <div></div>
</span>

Warning on console

div is not a valid child of span at /path/to/file.tsx:linenumber:position

Avoid escaping

All content of HTML tags and attributes are escaped by default to avoid XSS attacks. Similarly to React's dangerouslySetInnerHTML, you can disable escaping by using the raw function.

import { raw } from '@triptease/html-jsx';

const content = '<script>arbitraryCode()</script>';

<div>{content}</div> // Outputs <div>&lt;script&gt;arbitraryCode()&lt;&#x2F;script&gt</div>;
<div>{raw(content)}</div> // Outputs <div><script>arbitraryCode()</script></div>

Attribute escaping can also be disabled

import { raw } from '@triptease/html-jsx';

<hr data-x={raw('&')} /> // Outputs <hr data-x="&" />
<hr data-x={'&'} /> // Outputs <hr data-x="&amp;" />

Inline Javascript

TODO: Add documentation

Extend with Custom Elements

Define custom elements by extending the JSX.IntrinsicElements interface.

declare module '@triptease/html-jsx' {
  namespace JSX {
    interface IntrinsicElements {
      'some-custom-element': {
        someAttribute: string;
        children?: Children;
      };
    }
  }
}

<some-custom-element someAttribute="data">Foo</some-custom-element>