I would like to use one React project within another, but I would like to explain myself better.
How can I use these isolated React projects in a larger React project?
Yes, It is possible.
There are multiple ways to go about this.
This is usually referred to as micro front-ends. You could even have multiple React applications inside another React application. Even other frameworks such as Vue or Angular. Two ways to go about this:
A Single Single Page Application (Single SPA)
In this scenario you build multiple applications in one. A nice article about this is: Building Micro Frontends with React.
Split application into separate SPA's
The other option would be split the applications into separate SPA's. So you would build, and then deploy on a server, to load them in your app on the page you would like. Source: Hosting multiple react applications on the same document
If you want to re-use components, you could create a separate application in which you use storybook to create and maintain your components. From this project you distribute them to your other project(s).
If you keep this project in the same root as your react project, you can use them using relative imports.
If you don't want to publish it in the public registry, you can use a private npm registry.
There are two ways to go about this.
Paid private npm registries:
Host your own:
This will allow you to keep your npm packages from the public.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With