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

opeact.js

v1.2.0

Published

A simple Node.js library for embedding HTML in JavaScript without external dependencies.

Readme

Opeact is a simple Node.js library for embedding HTML in JS, eliminating the need for external dependencies.

Installation

$ npm install opeact.js

Dependencies

Opeact relies on two main dependencies:

Express JSDOM

Usage

import act from "opeact.js"

// Define routes
act.get("/home", "home.js"); // Reads home.js when accessing /home

act.get("/ping", (req, res) => {
    res.send("pong!");
}); // you can use express function directly.

// Start server
act.start(80);

Example home.js

// home.js
async (req, res) => {
    const document = 
    <html>
        <head>
            <title>Hello World!</title>
        </head>
        <body>
            <img src="/flower.jpg" width="250"/>
            <h1>Welcome to my website!</h1>
        </body>
    </html>;
    
    const text = <a>I love flowers.</a>;
    
    document.body.append(text);
    return document;
}

File Structure

The standard structure for files in Opeact follows this pattern:

() => {
    // Your code here
}
// Example with async
async () => {
    // Your asynchronous code here
}

When defining routes with external files (e.g., home.js), the JavaScript code must be wrapped within either an arrow function without parameters or an asynchronous arrow function. It's important to note that no code should exist outside of this function within the file.

Sending Responses

To send responses back to the user, you can use the following patterns:

Sending Strings

async () => {
    return "Hello world.";
}

Sending Objects/Arrays (JSON)

async () => {
    return {"fruits": ["apple", "banana", "pear"]};
}

And of course, send html elements/pages:

async () => {
    return (
        <html>
            <body>
                <h1>Hi there!</h1>
            </body>
        </html>
    );
}

When using HTML elements, ensure they are properly formatted within the return statement.

Manipulating Elements

You can manipulate HTML elements within your JavaScript code. For example:

const img = <img id="abc"/>
img.src = "/image.png"
img.style.width = "120px"
img.style.height = "200px"

And you can get element properties too.

const page = <body> <h1 class="a">Hi there!</h1> </body>
console.log(page.querySelector('.a').textContent) //"Hi there!"