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

als-render-jsx

v1.3.0

Published

Transform JSX-like code into plain JavaScript

Readme

als-render-jsx Documentation

als-render-jsx is a JavaScript library that transforms JSX-like code into plain JavaScript. It is designed to mimic JSX syntax while enabling runtime evaluation and rendering in both Node.js and browser environments.

Limitations and Flexibility

  • By default, als-render-jsx is intended to work with the als-component library, seamlessly integrating JSX-like components into projects.
  • The library is highly customizable. You can override its two core static functions:
    • RenderJsx.componentFn — to define how components are rendered.
    • RenderJsx.buildAction — to define how event handlers are processed.
  • With these overrides, the library can become universal and adaptable to various use cases.

Installation and Import

Install the library using npm:

npm i als-render-jsx

Importing

In a Node.js environment, import the library as follows:

const RenderJsx = require('als-render-jsx');

In the browser, include the library using a script tag:

Development Version

<script src="/node_modules/als-render-jsx/render-jsx.js"></script>

Minified Production Version

<script src="/node_modules/als-render-jsx/render-jsx.min.js"></script>

Basic Usage

Use the RenderJsx.render method to transform JSX-like code into plain JavaScript.

Example

Input

const component = /*js*/`class Some {
   constructor(props,inner) {super(props,inner)}
   render() {
      return (<div>{this.inner}</div>);
   }
}`;
const result = RenderJsx.render(component);
console.log(result);

Output

class Some {
   constructor(props,inner) {super(props,inner)}
   render() {
      return `<div>${this.inner}</div>`;
   }
}

Nested JSX Example

Input

const component = /*js*/`class Parent {
   constructor(props,inner) {super(props,inner)}
   render() {
      return (<div><Child>some inner</Child></div>);
   }
}`;
const result = RenderJsx.render(component);
console.log(result);

Output

class Parent {
   constructor(props,inner) {super(props,inner)}
   render() {
      return `<div>${new Child({},'some inner').call()}</div>`;
   }
}

rest attrubutes

class Input {
   constructor(props) {super(props)}
   render(props) {
      return (<input {...props} />);
   }
}
class Login {
   constructor(props,inner) {super(props,inner)}
   render() {
      return (<div>
         <Input {{ name:'email',placeholder:'Email',type:'email',required:true  }}>
         <Input {{ name:'password',placeholder:'password',type:'password',required:true  }}>
      </div>);
   }
}

Customizing componentFn and buildAction

als-render-jsx allows you to redefine two core functions to suit your needs.

RenderJsx.componentFn(isAwait, tagName, props, inner)

This function defines how components are rendered. By default, it returns an initialization of another component.

Default Behavior

RenderJsx.componentFn = function (isAwait, tagName, props, inner) {
   return `${isAwait}(new ${tagName}(${props}, \`${inner}\`)).call()`;
};

Async Prop

  • If a component includes the async={true} prop in the JSX, the isAwait parameter becomes true.

Example Override

You can customize the function to return a string representation for debugging:

RenderJsx.componentFn = function (isAwait, tagName, props, inner) {
   return `Debug: { isAwait: ${isAwait}, tagName: ${tagName}, props: ${props}, inner: ${inner} }`;
};

RenderJsx.buildAction([name, value])

This function processes event handlers and assigns listeners after the HTML is rendered.

Default Behavior

RenderJsx.buildAction = function ([name, value]) {
   const event = name.split('on')[1].toLowerCase();
   value = `$${this.action('${event}', ${value})}`;
   return [event, value];
};

Example Override

Customize it to log all event assignments:

RenderJsx.buildAction = function ([name, value]) {
   console.log(`Assigning event: ${name} with handler: ${value}`);
   return [name, value];
};

Advanced Examples

Multiple Components

Input

const components = /*js*/`class Parent {
   render() {
      return (<div><Child prop="value">Hello</Child></div>);
   }
}`;
const result = RenderJsx.render(components);
console.log(result);

Output

class Parent {
   render() {
      return `<div>${(new Child({prop: "value"}, \`Hello\`)).call()}</div>`;
   }
}

Custom componentFn and buildAction

Custom Function Definitions

RenderJsx.componentFn = function (isAwait, tagName, props, inner) {
   return `CustomComponent(${tagName}, ${props}, ${inner})`;
};

RenderJsx.buildAction = function ([name, value]) {
   return [`custom-${name}`, `handle(${value})`];
};

Input

const components = /*js*/`function App() {
   return (<div onClick={handleClick}>Click Me</div>);
}`;
const result = RenderJsx.render(components);
console.log(result);

Output

function App() {
   return `<div custom-onClick="handle(handleClick)">Click Me</div>`;
}

This demonstrates how you can fully control the behavior of the library to match your specific requirements.