Deploy a React Application to the Internet Quickly (And for Free)
Motivation
Over the last couple of weekends, I decided to revamp a personal project website and create a portfolio website for myself. In both cases, I reached for React, as it’s easy to setup and simple to add modular components, to display content in interesting ways.
Once I was happy with the results, I started to think about hosting. I didn’t really want to renew the hosting for the project website, and I definitely didn’t want to buy hosting for my personal site. Luckily, Github Pages offers free hosting (subject to some generous usage quotas). There are just a couple of very quick and simple steps to get your React application hosted using this service.
Install gh-pages
Assuming you have a React application, with an associated Github repo (which must be public), then you need to install gh-pages from npm. You’re going to make use of the CLI functionality of that package to deploy your React app.
Navigate to your project directory and run:
$ npm install gh-pages --save-dev
If you don’t have a React application, and you’d like to cookie cut one to follow along with this guide, you can run:
$ npx create-react-app my-app