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

@turtlemay/jsx-dom

v1.1.3

Published

Turn your JSX elements into native DOM elements.

Readme

@turtlemay/jsx-dom

This minimal, zero-dependency JSX factory allows you to use React-like design patterns with web components and other native DOM elements. Most JSX patterns and special attributes are supported.

npm (scoped)

Example

import * as React from '@turtlemay/jsx-dom'

// Define a custom element type.
class MyCustomElement extends HTMLElement {
  connectedCallback() {
    this.innerHTML = ''
    this.appendChild(<p>hello {MyCustomElement.name}</p>)
  }
}

// Register our custom element.
customElements.define(`x-${MyCustomElement.name.toLowerCase()}`, MyCustomElement)

// Use the custom element type like a React component.
document.body.appendChild(
  <MyCustomElement
    // Use the ref callback to save your element reference.
    ref={v => this._myElemRef = v}

    // Props matching a native property name will be assigned to that property.
    onclick={e => {}}
    // Camel cased event callbacks are also assigned via the corresponding native property.
    onMouseDown={e => {}}

    // Style objects are also supported.
    style={{ border: '1px solid red' }}

    // Anything else becomes a native attribute.
    my-string-attrib="foo"
    my-number-attrib={0}
    my-boolean-attrib={true}
    // Objects become json-stringified.
    my-object-attrib={{ foo: "bar" }} />
)

Installation

npm install @turtlemay/jsx-dom

Usage

Simply import the module into your JSX files using the React namespace:

import * as React from '@turtlemay/jsx-dom'

And write some JSX:

const attribs = {
  foo: 'foo',
  bar: 'bar',
}
const div = <div {...attribs} baz="baz" qux="qux" />

JSX elements become native DOM elements:

console.assert(
  <div /> instanceof HTMLDivElement
)

And fragments become document fragments:

console.assert(
  <></> instanceof DocumentFragment
)

Optional Configuration

With TypeScript you can use a namespace other than React by setting your tsconfig.json:

{
  "jsx": "react",
  "reactNamespace": "JSXFactory"
}
import * as JSXFactory from '@turtlemay/jsx-dom'

const div = <div />

Tips

Use a decorator for easy component registration:

// Decorator with optional tag name to define custom elements.
function registerComponent(tagName) {
  return type => {
    if (!tagName) tagName = 'x-' + type.name.toLowerCase()
    if (customElements.get(tagName)) return
    customElements.define(tagName, type)
  }
}

// Decorate your components.
@registerComponent()
class MyComponent extends HTMLElement {}

For passing non-serializable props, use an initializer:

@registerComponent()
class MyComponent extends HTMLElement {
  init(myArg) {
    // Use your arguments to perform initialization.
    return this
  }
}

document.body.appendChild(
  MyComponent.prototype.init.call(
    <MyComponent my-serializable-prop="" />,
    { myNonSerializableProp: Symbol() }
  )
)