reactjs - How to share React Components between projects -


i built component want use in separate projects. simplest best way reuse component across projects using npm?

you haven't indicated whether wish keep component private, i'm going answer 2 ways:

if going open-source component

this easiest: publish component(s) npm package (see docs here). install package other in projects using components.

if wish keep private

you have several options here:

  1. pay private modules on npm (docs here). if go route, can install package other.

  2. use npm link (docs) create link project(s) component package located on local storage. works kind of tricky set up. benefit of if rebuild component, projects link component see changes immediately.

  3. use npm install install (private) github or other repository. works normal npm install , little easier use npm link. downside changes component need pushed remote repository , project(s) using component need updated.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -