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

@barelyhuman/mage

v0.1.3

Published

stateful + logical abstraction layer for react

Downloads

25

Readme

Warning: This repo has been archived because a better more cleaner implementation of the event based re-render has been implemented with @preact/signals

Note: Please fork the repo if you wish to extend on this or use this instead. A final version of the same as been released in case people are using it.

@barelyhuman/mage

stateful + logical abstraction layer for react

Highlights

  • Tiny
  • 0 Deps

Usage

Note: The library depends on valtio, so please install valtio as well (ignore if already installed)

npm install @barelyhuman/mage valtio
# or
yarn add @barelyhuman/mage valtio
# or
pnpm add @barelyhuman/mage valtio

Quick Copy

import {createState, makeReactive} from '@barelyhuman/mage'

const state = createState({
	count: 0,
})

function inc() {
	state.count += 1
}

function CounterImpl() {
	return (
		<>
			<p>{state.count}</p>
			<button onClick={inc}>+</button>
		</>
	)
}

const Component = makeReactive(state)(CounterImpl)

export default Component

About

Note: This library isn't a mandatory requirement, most of what it does can be done by using something like valtio or jotai and maintaining local state in the component file and not inside the component and side effects being thrown out of your head and using manual action based triggers inside other actions. (how you'd write normal javascript)

The reason for mage to exist was to abstract and block the usage of hooks in functional components. This became necessary after libraries dropping support for class based components and specifically writing stuff for hooks (I'm also someone who's done this). So, this library is just to help you avoid writing hooks by giving a better way to write just javascript in react

Hooks, inherently aren't bad but the usage abuse of everything having to be a hook and libraries polluting this space ends up creating code where a functional component has more hooks than it has rendering logic.

This also ends up with mix and match between hooks that aren't composable.

For example, custom hooks that use redux and then manipulated hooks that use that redux state can cause a lot of re-renders, which can be avoided by using refs and a bit of diffing logic but that's not supposed to be that complicated.

This is where it's necessary for that abstraction to be taken up by a utility.

Docs

You can read more about the usage and API by checking the docs/pages folder in the repo or by visiting the web version →

Disclaimer

I have nothing against react, I like the library, I'm just not satisfied by the direction of how things are done when using it, so this is a disciplinary abstraction that forces you to write functional components as just that. A function that returns a component based on props.

License

MIT