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

naro

v0.2.0

Published

A tiny library for building UIs with template literals

Readme

naro

npm version license PRs welcome status stability

A tiny library for building UIs with template literals and a lightweight virtual DOM.

Installation

## Install using NPM
$ npm install --save naro

## Install using Yarn
$ yarn add naro

Usage

import { html, render } from "naro";

render(html`<div align="center">Hello world</div>`, document.getElementById("root"));

API

h(type, props[, ...children])

Creates a new VDOM Node element of the specified type, with the specified props and children.

import { h } from "naro";

h("div", { align: "center" }); // --> <div align="center"></div>

h("div", {}, "Hello world"); // --> <div>Hello world</div>

This method does not return a DOM element. It returns a Virtual DOM Node element, which is a JSON representation of the DOM element.

To transform it into a real DOM element, use render.

Type

The type argument should be either a tag name string (such as "div" or "a").

// Using a tag name
h("a", { href: "https://google.es" }, "Click me!"); 
// Renders to: <a href="https://google.es">Click me!</a>

Props

The props argument is an object with the data of the element. This can include HTML attributes, events listeners or custom properties that our functional element will use.

h("div", {
    className: "button",
    onclick: event => { /* Handle click event */ },
    id: "button1",
});
Class names

Use the className property to set the CSS class.

h("div", { className: "button" }, "Button");
Events

Attach a callback listener to an event.

h("div", {
    onclick: event => { /* Handle click event */ },
    onmousedown: event => { /* Handle mouse down event */ },
    onmouseup: event => { /* Handle mouse up event */ },
});
References

Use the ref property to save a reference of the element.

import { h, createRef, render } from "naro";

// 1. use n.ref to generate a reference variable
const inputRef = createRref();

// 2. assign inputRef to an element
render(h("input", { ref: inputRef }), document.getElementById("root"));

// 3. now you can access to the referenced element
console.log(inputRef.current.value);
Styles

You can provide an object with the style of the element. All styles attributes should be in camel-case format.

h("div", {
    style: {
        backgroundColor: "blue",
        color: "white",
    },
    align: "center"
}, "Hello");

html

A JavaScript template tag that converts a JSX-like syntax into a VDOM tree, that you can use with render.

Example:

import { html, render } from "naro";

const userHtml = render(html`
    <div align="center">
        <img className="avatar" src="/path/to/user.png" />
        <span>Hello user</span>
    </div>
`);

Features:

  • Dynamic props: <div align="${currentAlign}" />.
  • Dynamic content: <div>Hello ${name}</div>.
  • Events: <div onClick="${() => console.log("clicked")}"></div>.
  • Spread props: <div ...${extraProps}>.

render(element, parent)

Renders a VDOM Node to the DOM.

import { h, render } from "naro";

render(h("div", {}, "Hello world!"), document.getElementById("root"));

The first arguments is the VDOM Node to render, and the second argument is the parent DOM element. Returns a reference to the rendered DOM element.

createRef()

Returns a new object with a single key current initialized to null. Use this object to save a reference to rendered elements with render.

import { html, createRef, render } from "naro";

// 1. use n.ref to generate a reference variable
const inputRef = createRref();

// 2. assign inputRef to an element
render(html`<input ref="${inputRef}" />`, document.getElementById("root"));

// 3. now you can access to the referenced element
console.log(inputRef.current.value);

License

naro is released under the MIT LICENSE.