React Exercise and demo for github page deployment

Branch "main" includes the app files

Run npm install to install packages.

Run npm run dev to run the development server.

Branch "gh-pages" includes the deployed site files

Deployment done thanks to this tutorial with the following modifications to make it work:

  • replaced BrowserRouter with HashRouter (if you use React Router)
  • added a BASE reference in vite.config.js
  base: "/{repo_name}/"
  • replaced the deploy command on package.json to use the dist folder instead of build (as this project was created with vite)
    "deploy": "gh-pages -d dist"

If you already have the app created and connected to a github repo, you only need to do the Procedure steps 3, 4, 5, 7 and 8 of the tutorial above (install gh-pages, modify package.json, run npm run deploy).