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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@suckless/jsx

v0.6.0

Published

JSX-to-string runtime for server-side HTML rendering with XSS escaping and strict per-element types

Downloads

853

Readme

@suckless/jsx

JSX-to-string runtime for server-side HTML rendering. No virtual DOM, no framework, no hydration — JSX expressions evaluate directly to strings with automatic XSS escaping.

Install

bun add @suckless/jsx

Setup

Add the JSX pragma to files that use JSX:

/** @jsxImportSource @suckless/jsx */

Or configure it globally in tsconfig.json:

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

Usage

/** @jsxImportSource @suckless/jsx */

const page = (
	<html>
		<head>
			<title>Hello</title>
		</head>
		<body>
			<h1>Hello, world!</h1>
		</body>
	</html>
)
// page is a plain string: "<html><head><title>Hello</title></head>..."

Components

Function components receive props and return strings:

/** @jsxImportSource @suckless/jsx */
import type { Component } from "@suckless/jsx"

const Card: Component<{ title: string }> = (props) => (
	<div class="card">
		<h2>{props.title}</h2>
		{props.children}
	</div>
)

const html = (
	<Card title="Welcome">
		<p>Content here</p>
	</Card>
)

Escaping

All string children and attribute values are escaped by default:

/** @jsxImportSource @suckless/jsx */
import { raw } from "@suckless/jsx"

// Escaped (safe)
const safe = <div>{"<script>alert('xss')</script>"}</div>
// → <div>&lt;script&gt;alert(&#39;xss&#39;)&lt;/script&gt;</div>

// Unescaped (trusted content only)
const trusted = <div>{raw("<b>bold</b>")}</div>
// → <div><b>bold</b></div>

Fragments

/** @jsxImportSource @suckless/jsx */

const items = (
	<>
		<li>One</li>
		<li>Two</li>
	</>
)
// → "<li>One</li><li>Two</li>"

API

escape(value: string): string

Escapes &, <, >, ", and ' to their HTML entity equivalents.

raw(value: string): RawHtml

Wraps a string to bypass automatic escaping. Use only with trusted content.

Fragment(props: { children?: Children }): string

Renders children without a wrapper element. Used automatically by <>...</> syntax.

Type Safety

Every HTML and SVG element has strict per-element attribute types:

  • Void elements (<br>, <img>, <input>, etc.) reject children at the type level
  • Element-specific attributes are enforced (href on <a>, not on <div>)
  • Standard HTML attributes (class, for) — not React conventions
  • No event handler types — this is a server-side renderer
  • data-* and aria-* attributes are supported on all elements

License

MIT