A react website that deploys to GitHub Pages using GitHub Actions.
- ⚡ Vite + React + TypeScript
- 🔁
BrowserRouter(404 page added for SPA fallback trick) - 🚀 Zero-config CI deploy (this repo already contains the workflow)
Requirements: Node.js 20+ (LTS). On Windows, install from https://nodejs.org and accept the option to add Node to PATH.
npm install
npm run devgit init
git add -A
git commit -m "Initial commit"
git branch -M main
git remote add origin https://github.com/<YOUR_USER_OR_ORG>/<YOUR_REPO>.git
git push -u origin main- Open your repo → Settings → Pages.
- Under Build and deployment, set Source: GitHub Actions (the included workflow handles everything).
- Push to
mainanytime to redeploy.
The workflow builds with a BASE_PATH that matches your repo name so Vite emits correct asset URLs.
- If your repo is
<user>.github.io(user/organization site), it uses/. - Otherwise (project site), it uses
/<repo>/.
- In Settings → Pages, set your custom domain (e.g.,
www.example.com). - Create a
CNAMEDNS record pointing to<user>.github.io(or your org). - (Optional) Add a
public/CNAMEfile containing your domain so the Action publishes it automatically.
- Create
src/pages/YourPage.tsx - Add a
<Route path="/your-page" element={<YourPage/>} />insrc/App.tsx - Add a link in
src/components/NavBar.tsx
- "Could not determine Node.js install directory" (Windows): Reinstall Node.js LTS and ensure "Add to PATH" is checked. Then re-open your terminal.
- ESLint 'react-app' config error: This starter doesn't use CRA's ESLint preset. If you see this, you probably have leftover files from Create React App; start from a clean folder.
- Blank page after deploy: Make sure Pages is set to GitHub Actions, and the action completed successfully
(check the Actions tab). Also confirm that assets load from
/<repo>/...when it's a project site.
npm run dev # start dev server
npm run build # build to dist/
npm run preview # local preview of the production build