DEV Community

YJDoc2
YJDoc2

Posted on

How to create a new react npm package?

Hello, I want to create a new component package for react, which I might publish on npm later. I haven't done this before,so can you tell me the steps needed to setup a basic template for a new package, something like what create-react-app does, but for packages. Also most packages on npm have typscript types along with them, so would that require some extra setup steps? Please comment if you have any idea.

Thank you!

Top comments (4)

Collapse
 
kwaimind profile image
Daniel Reed

You should take a look at tsdx.io/

Sets up everything you need to make npm packages with TS and Jest. Also fixes all of the dist setup for CJS and ESM. I've used it a few times and its brilliant and super east.

Collapse
 
yjdoc2 profile image
YJDoc2

Hey, thanks for the reply!
This seems very cool, and very useful, Thanks for the info, I'll sure try it out πŸ‘ πŸ˜„

Collapse
 
kamilbugnokrk profile image
Kamil Bugno • Edited

There is CLI for creating reusable react libraries: github.com/transitive-bullshit/cre...

Collapse
 
yjdoc2 profile image
YJDoc2

Hey, thanks for the reply! πŸ˜„ πŸ˜„
I had actually checked this out before, but I didn't find any explanation for how to use it with TS, although it is said in Readme that it has optional TS support. Do you have any idea on how to make it work with TS?