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

@w-lfpup/react-superaction

v0.2.1

Published

Turn the virtual-dom into a declarative event-bus

Readme

react-superaction

Turn the virtual-dom into a declarative event-bus.

(a port of superaction for React)

Install

Install via npm.

npm install --save-dev @w-lfpup/react-superaction

Or install directly from github.

npm install --save-dev https://github.com/w-lfpup/react-superaction

Setup

Add a SuperActionProvider component to broadcast action events.

The SuperActionProvider component below listens for click events. React developers can access action events.

import React from "react";
import ReactDOM from "react-dom/client";

import { SuperAction } from "@w-lfpup/superaction";
import { SuperActionProvider } from "@w-lfpup/react-superaction";
import { Counter } from "./counter.js";

let rootEl = document.querySelector("#root")!;

let _superAction = new SuperAction({
	host: rootEl,
	eventNames: ["click"],
	connected: true,
	infix: "-", // react-safe-html-attributes
});

const root = ReactDOM.createRoot(rootEl);
root.render(
	<SuperActionProvider target={rootEl}>
		<Counter />
	</SuperActionProvider>,
);

Declare

Add an attribute with the pattern event-=action.

<button click-="increment">+</button>

Now the button dispatches ActionEvents when clicked.

Listen

The useAction hook connects action events to react-land.

import React, { useState } from "react";
import { useAction } from "@w-lfpup/react-superaction";

export function Counter() {
	let [count, setCount] = useState(0);

	useAction((action) => {
		if ("increment" === action.type) setCount(count + 1);
	});

	return <button click-="increment">{count}</button>;
}

An action has several properties related to an action event including:

  • the action type
  • the original dom event
  • the action event target
  • associated formData
let { type, event, target, formData } = action;

Form data is available when an action event originates from a element.

Event stacking

Superaction-js listens to any DOM event that bubbles. It also dispatches all actions found along the composed path of a DOM event.

Turns out that's all UI Events. Which is a lot of events!

Consider the following example:

<body click-="A">
	<div click-="B">
		<button click-="C">hai :3</button>
	</div>
</body>

When a person clicks the button above, the order of action events is:

  • Action "C"
  • Action "B"
  • Action "A"

Propagation

Action events propagate similar to DOM events. Their declarative API reflects their DOM Event counterpart:

  • event-prevent-default
  • event-stop-propagation
  • event-stop-immediate-propagation

Consider the following example:

<body click-="A" click-stop-immediate-propagation>
	<section click-="B" click-prevent-default>
		<button click-="C">UwU</button>
		<button click-="D" click-stop-propagation>^_^</button>
	</section>
</body>

So when a person clicks the buttons above, the order of actions is:

Click button C:

  • Action "C" dispatched
  • preventDefault() is called on the original PointerEvent
  • Action "B" dispatched
  • Action propagation is stopped similar to event.stopImmediatePropagation()
  • Action "A" does not dispatchß

Click button D:

  • Action "D" dispatched
  • Action event propagation stopped similar to event.stopPropagation()

Discrepencies

JSX and consequently React does not follow HTML spec. It transpiles HTML-looking syntax into a series of calls to a pragma function. It calls the function as many times as there are gator tags < declared.

In superaction the syntax looks like:

<button click:="do_something">click me!</button>

HTML considers : _ @ all valid characters for attributes. It's very flexible.

React / JSX is not HTML and restricts attribute characters to - and also _ but only AFTER a -.

So the syntax for superaction in react is limited to:

<button click-="do_something">click me!</button>

License

React-superaction is released under the BSD-3 Clause License.