Deploy your React application to GitHub pages

Chandan Rauniyar
5 min readJun 27, 2019

gh-pages -d build

Continuing from my previous post Mapping location data with Mapbox, I was looking for options to host the application online for free. Initially, I thought of using Amazon Web Services to host my application using their free tier. But 750 hours per month of EC2 instance usage would eventually run out if I have more than one instance up and running. Using AWS for hosting my React application wasn’t an option as I was looking for a permanent free solution.

I know GitHub pages allow hosting of a static site but I wasn’t sure if React application can be hosted on it. A quick search online and looks like GitHub pages can host React applications.

Here’s how I published my React application on GitHub pages.

There are a couple of ways to push the React application to GitHub pages. First is by manually creating a branch called gh-pages and using this branch to build GitHub pages for the repository. The second option is by using the npm package, gh-pages that will essentially do all the heavy lifting.

Option 1 — The hard way

--

--

Chandan Rauniyar

Senior Software developer | Visual learner | Love all things Android