To deploy your Create React App project to GitHub Pages, follow these steps:
npm install --save-dev gh-pagesThis tells GitHub Pages the base URL of your app:
"homepage": "https://{your-username}.github.io/{your-repo-name}"Replace {your-username} and {your-repo-name} with your actual GitHub details.
Update the scripts section in package.json:
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
}By default, CRA outputs the production build to the
build/directory.
If you haven’t already:
git init
git remote add origin https://github.com/{your-username}/{your-repo-name}.git
git add .
git commit -m "Initial commit"
git push -u origin mainnpm run deployThis will:
- Build the app
- Push the build output to the
gh-pagesbranch
Once deployed, your portfolio will be available at:
https://{your-username}.github.io/{your-repo-name}/
You can verify or configure the link under your GitHub repository’s Settings → Pages.
npm install
npm startHappy deploying 🚀