What is react.js?
What is Bootstrap?
Bootstrap is the most popular front-end development framework for building responsive web layouts with many components.
I do not recommend using bootstrap.because bootstrap increase HTML and CSS file size.
1. Add Bootstrap in React Using NPM:
use this command to install bootstrap in our project.
npm install bootstrap --save
After installing the bootstrap, you will need to import the CSS file in your React app entry file.
If you generated your project using the create-react-app tool, open the src folder find the entry file paste.
You will also need to install the jquery and popper.js packages from npm. In your terminal, run the following commands:
npm install jquery popper.js
Next, go to the src/index.js file and add the following imports:
import $ from 'jquery'; import Popper from 'popper.js'; import 'bootstrap/dist/js/bootstrap.bundle.min';
2. Adding Bootstrap in React Using CDN:
In this method, you are integrating Bootstrap with React, i.e., via a CDN. This approach is easy for everyone because you need only add a
<link> tag for Bootstrap CDN.
Go to your project’s root folder, open the
public/index.html file, and paste this code in the
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
Add the following CDN file before the closing