Overview
School Science is a static React application built with Vite, making it easy to deploy to various hosting platforms. This guide covers deployment to popular services.Vercel Deployment (Recommended)
Vercel offers the fastest and easiest deployment for Vite applications, with zero configuration required.Automatic Deployment from GitHub
Connect to Vercel
- Visit vercel.com
- Sign up or log in with your GitHub account
- Click “Add New Project”
- Import your School Science repository
Configure Project
Vercel auto-detects Vite settings:
- Framework Preset: Vite
- Build Command:
npm run build - Output Directory:
dist - Install Command:
npm install
Every push to your main branch automatically triggers a new deployment. Preview deployments are created for pull requests.
Vercel Configuration File
The project includesvercel.json for proper SPA routing:
vercel.json
/proyecto/franklin-bell) work correctly.
Vercel CLI Deployment
Deploy directly from terminal:Netlify Deployment
Netlify is another excellent option for static sites.Automatic Deployment from GitHub
Connect Repository
- Visit netlify.com
- Click “Add new site” → “Import an existing project”
- Connect your GitHub account and select repository
Configure Build Settings
Set these build parameters:
- Build command:
npm run build - Publish directory:
dist - Base directory: (leave empty)
Netlify CLI Deployment
GitHub Pages Deployment
Deploy to GitHub Pages for free hosting.Configuration Steps
Custom Domain Setup
Vercel Custom Domain
Netlify Custom Domain
Configure DNS
Option 1 - Use Netlify DNS (easiest):
- Transfer DNS management to Netlify
- Update nameservers at registrar
Environment Variables
If you add API keys or other sensitive data:Vercel Environment Variables
- Project Settings → Environment Variables
- Add variables:
- Redeploy for changes to take effect
Netlify Environment Variables
- Site settings → Build & deploy → Environment
- Add variables with same format
- Trigger manual deploy
Using in Code
Access environment variables:Build Optimization
Reduce Bundle Size
Optimize your build:vite.config.js
Image Optimization
- Compress images before adding to project
- Use WebP format for better compression
- Lazy load images for faster initial load
Code Splitting
Lazy load routes:src/App.jsx
Performance Monitoring
Vercel Analytics
Enable analytics in Vercel dashboard:- Project → Analytics tab
- Enable Web Analytics
- View metrics:
- Page views
- Load times
- Geographic distribution
- Real User Metrics (RUM)
Lighthouse Testing
Test your deployed site:- Performance: >90
- Accessibility: >95
- Best Practices: >95
- SEO: >90
Continuous Deployment
Automatic Deployments
Both Vercel and Netlify support:- Production: Deploys from
mainbranch - Preview: Deploys for every pull request
- Branch Deploys: Automatic deploys for specific branches
GitHub Actions
Custom deployment workflow:.github/workflows/deploy.yml
Troubleshooting
404 errors on refresh
404 errors on refresh
Problem: Navigating to
/proyecto/franklin-bell directly returns 404Solution: Add redirect rules:- Vercel: Already configured in
vercel.json - Netlify: Add
public/_redirectsfile - GitHub Pages: Not fully supported, consider hash router
Build fails on deployment
Build fails on deployment
Common causes:
- Missing dependencies in
package.json - Environment variables not set
- Build command incorrect
- Node version mismatch
- Check build logs for specific error
- Verify
npm run buildworks locally - Ensure Node version matches (18.x recommended)
Assets not loading
Assets not loading
Problem: Images or PDFs return 404Solution:
- Verify files exist in
public/directory - Check paths start with
/(e.g.,/image/photo.jpg) - Clear CDN cache and redeploy
Slow initial load
Slow initial load
Solutions:
- Implement code splitting with lazy loading
- Compress images (use WebP format)
- Enable CDN caching
- Reduce bundle size with tree shaking
- Use Lighthouse to identify bottlenecks
Post-Deployment Checklist
After deploying, verify:- Home page loads correctly
- All project cards display
- Project detail pages load
- Images load from all projects
- Videos embed properly
- PDF downloads work
- Routing works (direct URL access)
- Mobile responsive design
- HTTPS enabled
- Custom domain configured (if applicable)
- Analytics tracking (if enabled)
Related Resources
Vercel Documentation
Official Vercel deployment docs
Netlify Documentation
Official Netlify deployment docs
Vite Deployment Guide
Vite’s official deployment guide
GitHub Pages Guide
GitHub Pages documentation