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

@suranjitnamasudra/publish-react-npm

v1.0.6

Published

create a react npm packages

Downloads

41

Readme

Create and Publish your own react npm packages

A. Create a New Directory for the Package: ( create a project folder )

    1. Initialize a New npm Package:
npm init
    1. Make sure that while initialzed the npm packages your package name will be like that
  • a. "name": "@suranjitnamasudra/publish-react-npm"

  • b. "license": "MIT",

    1. Install Required Dependencies:
npm install react react-dom
npm install --save-dev @babel/core @babel/cli @babel/preset-env @babel/preset-react
    1. Set Up Babel:
  • Create a .babelrc file with the following content:
{
  "presets": ["@babel/preset-env", "@babel/preset-react"]
}
    1. Create a src folder inside the projects
    1. Create your React component file inside the src folder (e.g., MyComponent.jsx)
    1. Write the following code for the components.
// src/MyComponent.jsx
import React from 'react';

const MyComponent = ({ message }) => {
    return <div style={{ color: 'blue', fontSize: '20px' }}>{message}</div>;
};

export default MyComponent;

Important Notes:

  • If you are using css module or seperate css file make sure that file path should comes from the disk folder. like if i have a css file inside the ( src/MyComponents.module.css ) which is linked with my components then make sure that file path comes like that (../src/MyComponents.module.css ). so when we run the npm build commond it push ( MyComponents.jsx file ) to the dest folder and start create dependency tree So, that we have to make sure that we comes out of the ( dest ) folder then go inside the src folder and find the ( MyComponents.module.css file ). example ( import styles from '../src/MyComponent.module.css' ).

    • XXX---- Don't make like this ( import styles from './MyComponent.module.css') ----XXX

Step 3: Configure the Build Process

  1. Add a build script in your package.json:
"scripts": {
    "build": "babel src --out-dir dist"
}
  1. Build the package:
npm run build
  • This will transpile your code from src to a dist folder using Babel.

Add Package Metadata

  1. Update your package.json
  • Ensure it specifies the entry points
"main": "dist/MyComponent.js",
"files": [
    "dist"
]
  1. Add the peerDependencies field to specify React as a peer dependency it should exact matching version with your react and react-dom that you install as a dependency
"peerDependencies": {
     "react": "^18.3.1",
    "react-dom": "^18.3.1"
}

Publish the Package

  1. Log in to npm:
npm login
  1. Publish the Package:
npm publish --access public
  • If you encounter a naming conflict, change the name field in package.json (e.g., @yourusername/my-react-package).

Use the Package in Another Project

  1. Create a New Project:
npx create-react-app test-app
  1. Install Your Package:
npm install @suranjitnamasudra/publish-react-npm
  1. Use Your Component: Update App.js:
import React from 'react';
import MyComponent from '@suranjitnamasudra/publish-react-npm';

const App = () => {
    return (
        <div>
            <h1>Testing My React Package</h1>
            <MyComponent message="Hello from MyComponent!" />
        </div>
    );
};

export default App;
  1. Run the Project:
npm start

Steps for Update the Package when anything change:

  1. Make changes to your package.
  2. Increment the version in package.json:
  3. run build commond
  1. publish updated npm packages
npm publish --access public