Integrate a Bootstrap HTML template in your React.js App
Tags: react, javascript, tutorial, webdev
Published: 2019-01-10 08:45:22

---
title: Integrate a Bootstrap HTML template in your React.js App
published: true
description: Integrate a Bootstrap HTML template in your React Application
tags: React,javascript,tutorial,webdev
---
<img src="https://thepracticaldev.s3.amazonaws.com/i/lfy6a4b59pt224vcben4.jpg"/>

Hello, if you are here I can only guess that you want to create a new React application and use a bootstrap template because it’s just awesome and saves you considerate time OR that you are curious on how to integrate the template into the React project. For this article I presume you already had contact with React and know how to create a new project. If not, read this article first because it’s a good start: https://reactjs.org/docs/create-a-new-react-app.html

Bellow are the steps I took to accomplish this task.

<b>1. Find a template you like</b>

This is not always easy but with a bit of research you can find something appropriate. Keep in mind the scope of the application and that will narrow down the options. So far I really like the templates from Bootstrapious.com because they are clean and nicely implemented. You can use it for personal or commercial use if you keep the original credits from the template or make a donation to be able to delete that (check out their website for more info).

<b>2. Find beautiful artistic resources</b>

You might want to have something nice and artsy on your website. I absolutely love https://undraw.co/ and https://unsplash.com/.

<b>3. Scaffold empty pages</b>

For each page from the template you will need to have a corespondent React component.
<img src="https://thepracticaldev.s3.amazonaws.com/i/wv47qnp9ynuch5bst59p.PNG"/>

<b>4. Live check style changes</b>

Open terminal and run > yarn start

This will open a tab in your preferred browser and here is where you always check your modifications. If you modify in styles only, you will need to refresh the page to re-render though.

<b>5. Copy the needed resource files and folders from the template to the React app</b>

Copy all the required Stylesheets, JavaScript files, Fonts and any other resources from the template directory into the public folder of the React app. Next we need to declare and reference them in the public/index.html file from the template index page.

<img src="https://thepracticaldev.s3.amazonaws.com/i/jk466mlumi15rl1s8aen.png"/>

<b>6. Start using the html code in your components</b>

Now we need to start rendering the template in our React project. To do so I separate the task into two steps:

a) I bluntly copy the <body> section from html template file into the render function in my component.

<img src="https://thepracticaldev.s3.amazonaws.com/i/wffnjrkxyvw84vk2pjkw.png"/>

b) Usually the code won’t compile because some tags are not closed. Look for < img >, < hr > etc. and be sure to close them. I found this more as a trial and error stage because it depends on the template, but it definitely should work in the end if the template itself works.

That’s it.

<img src="https://thepracticaldev.s3.amazonaws.com/i/zfe1hsqxzcohp5ethkh2.png"/>

The above steps are what I gathered from my experience so far and I hope it will help you. I would be very happy to learn of better and new ways to do this, so thank you in advance for your ideas and help.