Publishing React application to GitHub Pages personal site instead of project repository

I’m struggling with getting my React application to work on my personal GitHub Pages site. Most tutorials I find online show how to set it up for project repositories, but I need it to work on my main user GitHub Pages.

I’ve been experimenting with modifying the gh-pages configuration in my package.json to point to the main branch instead of creating a separate branch. However, the deployment process still seems to require pushing to a gh-pages branch rather than deploying straight from my main branch.

Is there a way to configure the build process so it can deploy my React app directly from the main branch to my personal GitHub Pages? I want to avoid having to manage multiple branches for deployment.

yep, you gotta do some extra stuff. GitHub Pages grabs user sites from the main branch’s root. You might wanna set up a GitHub Action that builds automatically when you push to main - it’ll take care of all the build files for ya.

I encountered a similar issue previously. Personal GitHub Pages serves directly from the root of your main branch, unlike project pages which use a gh-pages branch. What worked for me was to keep my React code in a different branch and compile it to a ‘dist’ folder in the main branch. After development, I used a script that builds and syncs the dist folder to my main branch. While GitHub Actions is an option, I preferred a manual method as it gave me precise control over deployment times.