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

chalk-iria

v1.2.2

Published

Pre-conditions: > Create an npm account and login. You can either login from the npm website or from the CLI by running npm login.

Readme

#Publish React components as an npm package

Pre-conditions:

Create an npm account and login. You can either login from the npm website or from the CLI by running npm login.

A React app. I created the boilerplate for this article with npx create-react-app npm-test. Run the app on your local machine.

  1. Create and isolate components to publish

In the boilerplate app, I went into the src folder and deleted everything besides App.js, app.css, and index.js. I also added a folder called lib that will store everything I want to publish on npm. Inside lib , there is a folder called components to store the component elements and a file called index.js to export them.

Inside the components folder, I create new files called, which will be the components to use from the npm package.

These components are both in the components folder. Then, we’ll add them to the index.js file outside components folder:

importLogin from './components/Login';

export {Login };

  1. Install Babel and build the dist folder To install Babel, run the following in the CLI: npm install --save-dev @babel/core @babel/cli @babel/preset-env npm install -save @babel/polyfill

In the top-level folder of your project, add a file called babel.config.json and add the following presets:

{ "presets": [ [ "@babel/env", { "targets": { "edge": "17", "firefox": "60", "chrome": "67", "safari": "11.1" }, "useBuiltIns": "usage", "corejs": "3.6.5" } ], "@babel/preset-react" ] }

@babel/env tells the browser which versions it should target, and @babel/preset-react allows Babel to compile JSX.

In package.json , under scripts, replace the build script with the following:

"build": " babel src/lib -d dist --copy-files", or

"build": "rm -rf dist && NODE_ENV=production babel src/lib --out-dir dist --copy-files";

This will copy the src/lib to a new folder called dist . This folder is invisible but will be added to your root folder after build. Run the command npm run build in the CLI. If your build was successful and you write ls -a in the root folder, you will see a new folder called dist :

  1. Alter the package.json for publishing

This is the good part! The package.json must be changed to publish to npm.

This is the first part of my package.json:

"name": "npm-test", "version": "0.1.0", "private": true,

The name here has to be a unique name that hasn’t been taken by an existing npm package (you can check if a name is taken using npm search). version is the package version, and must be changed whenever it’s republished. Version syntax indicates major, minor, and patch releases and more about it can be found here in the npm docs. description, keywords, and author are all optional fields that will give potential end users a better idea of the package. Full package.json here.

"name": "Chalk-iria", "description": "Two test React components", "author": "",

"version": "0.1.0", "private": false, "main": "dist/index.js", "module": "dist/index.js", "files": [ "dist", "README.md" ],

The file is ready for npm publish.

  1. Use the new package Check in the CLI and on your npm profile that the package has published. To make sure it’s working, open a different project on your local machine, and try to use the package: npm install chalk-iria In the new project, try to use one of your components by importing it:

App.js import { Button } from 'jawblia'; import Flex from './layout/Flex'; function App() { return (

In the browser, we see: NPM package ui