Search code examples
reactjstwitter-bootstrap-2

I want to use bootstrap's cdn in my react project. Where and how do I insert the cdn?


I am currently working on a React single page application and I cannot figure out where and how to place the Bootstrap CDN in my project for my bootstrap to work.

Also if somebody could suggest how to npm install bootstrap for your project.


Solution

  • If you use create-react-app there is a file in public/index.html or let's say in your index html page which you first render use cdn there like

    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
        <meta name="theme-color" content="#000000">  
        <link rel="manifest" href="%PUBLIC_URL%/manifest.json">
        <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
        <!-- Latest compiled and minified CSS -->
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap.min.css">
        <title>React App</title>
      </head>