Toolkit for Publishing your React Component to the Node Package Manager(NPM)

Co-Founder, @CreoWis | Teacher, @tapaScript | Founder, @ReactPlay | YouTuber | Writer | Human
Search for a command to run...

Co-Founder, @CreoWis | Teacher, @tapaScript | Founder, @ReactPlay | YouTuber | Writer | Human
Bolaji Ayodeji, Thanks for liking it! Appreciate. Yeah, this tool automation is helping me 😊.
Traditional SSR is great, but it has a massive buffering problem. Let's look into the SSR Streaming and learn how it could be a game changer.

Learn how to build maintainable, reusable forms in React using design patterns like custom hooks, compound components, and context for scalable CRUD

Learn how JavaScript variables work, including let vs const, primitive and reference types, pass by value, and how JavaScript stores data in memory.

A beginner-friendly introduction to JavaScript covering what it is, how it works, and how to set up your JavaScript environment

Learn how the promises are handled internally using event loop. This concept is essentials to debug and work with async programming.

GreenRoots Blog - A Blog by Tapas Adhikary
186 posts
Educator | YouTuber | Building ReactPlay | Let's Connect
Today we are part of the ever-growing react community all over the world. Many react developers continuously creating open-source react components and publishing them to the npm repository. The entire ecosystem is an awesome place to be as a Reactjs developer.
In this article, I will introduce you to a toolkit that will help build, package, test, and publish your react component much faster way. The only motivation behind creating the toolkit was, it may encourage you as a react developer to make your re-usable component a public npm package for others to use.
Suppose you are already aware of creating an npm package and publish it, great! If not, you can check this article: Build, Test and Publish your NPM, I just did it in few minutes! I am going to explain some of the steps here anyway.
A reactjs component has to go through the following steps before it becomes a part of the npm repository as a reusable package,
index.js.dist.npm pack command. This tarball can be pointed from any other react project as a dependency and tested out.npm login. If you do not have a login credential yet, please create one from here.dist folder using the npm publish command.A picture is worth a thousand words. Here are the steps,
Steps involved in publishing a react component as npm
You may choose to remember and perform all the above steps again and again for publishing your remarkable react component. Otherwise, you can automate things in a script such that you focus on writing your component's logic. All other operational parts are taken care of by the script.
react-package-publisher provides a centralized script to take care of all that required for publishing to npm. You have to make sure you have created an account with npm repository as a prerequisite.
react-package-publisher.package.json with your package name, version, author, license, dependencies, devDependencies, etc. Please note, the peerDependencies are already set for a specific version of react and react-dom. Please feel free to change the versions suitable to your need. If you are new to npm dependency management, please read this.Run the build.sh file. Please use a UNIX-based terminal(example, GitBash) to run the build.sh file. That's all.
You should start seeing the output being logged like the one shown below. At the end of it, your component should be published as a package to the npm repository.
Logs while publishing to npm
If you find any issues or improvement requests, please log them here. If you like the work, please give the repo a star 🌟!
This toolkit is nothing more than a script that automates many things that you have to remember and execute. I find happiness in creating such scripts which are useful and can save time.
I hope you will use it to publish your super cool react component to the npm repository. You are completely free to bring any changes and enhancements to the tool or become a collaborator! See you there.
The cover image is an improvisation done on top of a Design by Freepik.
If it was useful to you, please Like/Share so that it reaches others as well. To get e-mail notifications on my latest posts, please subscribe to my blog by hitting the Subscribe button at the top of the page.