A modern, production-ready template for React applications with automatic GitHub Pages deployment.
- Node.js (version 22+ recommended - required by Vite 7+)
- npm
-
Click "Use this template" button on GitHub to create a new repository
-
Clone your new repository:
git clone https://github.com/[your-username]/[your-repo-name].git cd [your-repo-name]
-
Run the setup script:
npm install node setup-template.js
This will configure the project name and update all necessary files.
-
Start developing:
npm run dev
If you prefer to set up manually:
- Update the
name
field inpackage.json
to match your repository name - The
vite.config.ts
will automatically use this name for the GitHub Pages base path - Update the title in
index.html
if desired
This template includes automatic deployment via GitHub Actions:
-
Enable GitHub Pages:
- Go to your repository Settings β Pages
- Select "GitHub Actions" as the source
-
Push to main branch - deployment happens automatically!
-
Your app will be live at:
https://[your-username].github.io/[repository-name]/
- β‘ Vite - Lightning fast build tool and dev server
- βοΈ React 19 - Latest React with TypeScript support
- π GitHub Pages Ready - Pre-configured deployment workflow
- π£οΈ SPA Routing Support - 404.html for client-side routing
- π§ Auto Configuration - Base path automatically set from package.json
- π± Modern Setup - ESLint, TypeScript, and modern tooling
- π¨ Clean Structure - Well-organized project structure
npm run dev
- Start development server with hot reloadnpm run build
- Build optimized production bundlenpm run preview
- Preview production build locallynpm run lint
- Run ESLint for code qualitynpm run deploy
- Build the project (used by GitHub Actions)
βββ .github/
β βββ workflows/
β βββ deploy.yml # GitHub Pages deployment workflow
βββ public/
β βββ 404.html # SPA routing support for GitHub Pages
β βββ vite.svg
βββ src/
β βββ assets/ # Static assets
β βββ App.tsx # Main App component
β βββ App.css # App styles
β βββ main.tsx # React entry point
β βββ index.css # Global styles
βββ index.html # HTML template
βββ vite.config.ts # Vite configuration (auto-configured for GitHub Pages)
βββ package.json # Dependencies and scripts
βββ setup-template.js # One-time setup script
The vite.config.ts
automatically configures the base path for GitHub Pages:
- Development: Uses
/
for local development - Production: Uses
/[package-name]/
for GitHub Pages deployment
The deployment workflow:
- Triggers on pushes to
main
branch - Uses Node.js 18 with npm caching
- Builds and deploys to GitHub Pages automatically
- Includes proper permissions for Pages deployment
The public/404.html
file enables client-side routing by serving the React app for all routes, making React Router work seamlessly on GitHub Pages.
- Modify
src/App.css
andsrc/index.css
for styling - The template uses vanilla CSS, but you can easily add:
- Tailwind CSS
- Styled Components
- Material-UI
- Or any other styling solution
npm install [package-name]
Create .env
files for environment-specific configuration:
# .env.local
VITE_API_URL=https://api.example.com
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open source and available under the MIT License.
If you have any questions or run into issues:
- Check the GitHub Issues for existing solutions
- Create a new issue if you need help
- Check the Vite documentation for build-related questions
- Check the GitHub Pages documentation for deployment issues
Happy coding! π