DEV Community

Cover image for Deploying your ReactJS App to Github Pages
April Smith
April Smith

Posted on • Edited on

9 1

Deploying your ReactJS App to Github Pages

Why host your React portfolio app with GitHub Pages?

  1. It's Free!
  2. Real time updates
  3. Making your code open-source, It is a great way to showcase your skills Custom-domain, if you have existing domain, you can add a CNAME file to your repository
  4. It's Easy!

Note: GitHub Pages is a static service and does not support server-side scripting such as, PHP, Ruby, or Python.

Here is a new quick tutorial on how to deploy your reactJS application via Github Pages. I still prefer Heroku for dynamic web apps but here is the quick guide if you have a very simple React App and wanted to deploy it quickly to add it to your Frontend Development skills portfolio

Steps:

Note: I am using yarn as my package manager.
I already created my github repo and React project

  1. Install GitHub Pages package as a dev-dependency
yarn add gh-pages 
Enter fullscreen mode Exit fullscreen mode
  1. Add properties needed to package.json file
"homepage": "http://{github_username}.github.io/{your-app-repo-title}"
"scripts": {
  //...
  "predeploy": "yarn run build",
  "deploy": "gh-pages -b master -d build"
}
Enter fullscreen mode Exit fullscreen mode
  1. Then Deploy it in your local terminal
yarn deploy
Enter fullscreen mode Exit fullscreen mode

And Done! The branch that Github pages used is the gh-pages not the master. Everytime you deploy it will update the gh-pages branch.

You can now check your app at this URL format: http://{github_username}.github.io/{your-repo-title}

Alt Text

Tiugo image

Modular, Fast, and Built for Developers

CKEditor 5 gives you full control over your editing experience. A modular architecture means you get high performance, fewer re-renders and a setup that scales with your needs.

Start now

Top comments (2)

Collapse
 
makampos profile image
Matheus de Campos

Very simple!

Collapse
 
aralovelace profile image
April Smith

yes it is! I love React!

Neon image

Next.js applications: Set up a Neon project in seconds

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Get started →

👋 Kindness is contagious

Explore this insightful post in the vibrant DEV Community. Developers from all walks of life are invited to contribute and elevate our shared know-how.

A simple "thank you" could lift spirits—leave your kudos in the comments!

On DEV, passing on wisdom paves our way and unites us. Enjoyed this piece? A brief note of thanks to the writer goes a long way.

Okay