Search code examples
reactjsnpmcdnreact-bootstrap

Does React-Bootstrap need both npm install bootstrap and bootstrap CDN or just one of them?


I've seen two kinds of tutorials for React-Bootstrap.

Sometimes the tutorials show to install both React-Bootstrap and Bootstrap with npm install react-bootstrap bootstrap and then add the CDN link for Bootstrap in the index.html.

Then in other tutorials, it's just npm install react-bootstrap + CDN for Bootstrap in index.html


For example, Youtuber called Brice Ayres has this video: https://www.youtube.com/watch?v=tOK9l5uP06U ,

where he makes a website with React, React-Bootstrap, React-Router and Styled-Components.

On the video, he installs both React-Bootstrap and Bootstrap, and then adds the CDN link.


On the React-Bootstrap homepage https://react-bootstrap.github.io/getting-started/introduction, there's a text like this:

If you plan on customizing the Bootstrap Sass files, or don't want to use a CDN for the stylesheet, it may be helpful to install vanilla Bootstrap as well.

So I believe that it's up to the programmer to either choose to install Bootstrap with NPM or use a CDN link. Having both of them sounds a bit wierd in this.

Or have I misunderstood the use-case of the NPM Bootstrap package? Because I've thought that it's the same stylesheet as the CDN stylesheet?


Long story short: Is it enough to install just react-bootstrap and then add the CDN?


Solution

  • You need the Bootstrap.css file because its not part of the reactstrap packages...

    for this you need either

    1. npm install bootstrap and refer to the css file via an import statement in your JS
    2. add the CDN <link href=' ../> inside the index.html file...

    For deploying your web project to live, CDN will give a greater coverage for global audiences so you have to weigh the CDN vs local package value proposition based on your unique factors