Coder Social home page Coder Social logo

pmabiala / custom-hook-npm Goto Github PK

View Code? Open in Web Editor NEW

This project forked from atapas/custom-hook-npm

0.0 0.0 0.0 32 KB

This is a boilerplate to create NPM package for one or more ReactJS custom hooks and components.

License: MIT License

JavaScript 100.00%

custom-hook-npm's Introduction

Custom Hook NPM

This is a boilerplate to create an NPM package for one or more ReactJS custom hooks and components. I hope you find it helpful.

🫶 Support

Liked it? You can show your support with a STAR(⭐).

Many Thanks to all the Stargazers who has supported this project with stars(⭐)

Thanks to all stargazers

Sponsor My Work

I am an independent educator who creates meaningful projects to teach programming. You can support me further by sponsoring me on GitHub.

How to use it?

You can use the project in this way:

Install

    1. Clone this repository and change the directory to the project folder.
    1. Edit the package.json file to change the package name, author info, and GitHub link info as per your information.
    1. Run npm install in the root directory of your project.
    1. Add your React component and hooks. Hooks to go inside the hooks folder.

Build

You can build the project in two ways:

    1. yarn build: To build the project with a source map.
    1. yarn build: prod. This will generate minified files without a sourcemap.

NPM Pack for test

After building, create a npm locally to test:

npm pack: this command will generate the tar npm package file that you can take to any React-based projects(including Next.js) and use it.

  • Just copy the tar npm package file into your ReactJS/Next.js project folder.
  • Add this line to your project's package.json file:
    "<NPM-PACKAGE-NAME>": "file:<PATH-TO-THE-TAR-PACKAGE-FILE>",
    Please note the NPM-PACKAGE-NAME should be the same as the name you provided in the package.json file after cloning this repo.
  • Now you can check the node-modules folder to see if a new folder has been created with the NPM-PACKAGE-NAME. Then your installation is successful.

Publish It

  • To publish it, you must have an account on https://www.npmjs.com.
  • Make sure to be in this project folder.
  • Now, open a command prompt/terminal and execute this command to login:
    npm login
    
  • Please provide the credentials you have created already. You can also check if you are in the session with the following command,
    npm whoami
    

The next part is just to run the the publish command,

 npm publish

Happy Publishing!

custom-hook-npm's People

Contributors

atapas avatar pmabiala avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.