Prerequisites
Before deploying, ensure you have:- A working Goalst application locally
- Supabase project configured (see Setting up Supabase)
- A hosting platform account (Vercel, Netlify, Cloudflare Pages, etc.)
Build process
Goalst uses Vite for building and bundling. The build process compiles TypeScript, bundles assets, and optimizes for production.Understanding the build command
package.json
tsc -b- Runs TypeScript compiler to check typesvite build- Bundles the application for production
Local build test
Test your production build locally before deploying:Preview the build
http://localhost:4173 (default Vite preview port).Environment variables
Your production environment needs these variables:Environment variable handling
Vite exposes environment variables prefixed withVITE_ to your client-side code:
src/shared/constants/supabase.ts
The
VITE_ prefix is required. Without it, variables won’t be available in your application.Deployment platforms
Vercel
Vercel offers excellent Vite support with zero configuration.Connect your repository
- Go to vercel.com
- Click Add New Project
- Import your Goalst repository
Configure build settings
Vercel auto-detects Vite projects. Verify these settings:
- Framework Preset: Vite
- Build Command:
npm run build - Output Directory:
dist - Install Command:
npm install
Add environment variables
In your Vercel project settings:
- Go to Settings > Environment Variables
- Add
VITE_SUPABASE_URL - Add
VITE_SUPABASE_ANON_KEY - Make sure they’re available for Production, Preview, and Development
Netlify
Netlify provides simple drag-and-drop deployment or Git integration.Connect your repository
- Go to netlify.com
- Click Add new site > Import an existing project
- Connect your Git provider and select your repository
Add environment variables
In Site settings > Environment variables:
- Add
VITE_SUPABASE_URL - Add
VITE_SUPABASE_ANON_KEY
Configure redirects (important)
Create a This ensures React Router works correctly.
public/_redirects file for SPA routing:public/_redirects
Cloudflare Pages
Cloudflare Pages offers fast global CDN deployment.Connect your repository
- Go to pages.cloudflare.com
- Click Create a project
- Connect your Git account and select your repository
Configure build settings
- Framework preset: Vite (or None)
- Build command:
npm run build - Build output directory:
dist
Add environment variables
In the build configuration:
- Add
VITE_SUPABASE_URL - Add
VITE_SUPABASE_ANON_KEY
Docker deployment
For containerized deployments, use this Dockerfile:Dockerfile
nginx.conf for SPA routing:
nginx.conf
Supabase configuration for production
Update allowed URLs
In your Supabase dashboard:Verify CORS settings
Ensure your domain is allowed in Supabase’s CORS settings:- Go to Settings > API
- Verify your domain is listed or
*is enabled (not recommended for production)
Performance optimization
Build optimizations
Vite automatically applies these optimizations:- Code splitting: Splits code into smaller chunks
- Tree shaking: Removes unused code
- Minification: Reduces bundle size
- Asset optimization: Compresses images and fonts
Additional tips
Enable compression
Enable Gzip or Brotli compression on your hosting platform for smaller transfer sizes.
Use a CDN
Serve static assets from a CDN to reduce latency.
Lazy load routes
Use React lazy loading for route-level code splitting.
Monitor bundle size
Use
vite-bundle-visualizer to analyze your bundle and identify large dependencies.Custom domain setup
Most hosting platforms offer custom domain configuration:Continuous deployment
Most platforms support automatic deployments:- Push to main branch → Deploys to production
- Push to feature branch → Creates preview deployment
- Open pull request → Generates preview URL
Monitoring and debugging
Production error tracking
Consider integrating error tracking:Health checks
Verify your deployment:Authentication works
Authentication works
Test signing up, signing in, and signing out with a new account.
Routing functions
Routing functions
Navigate to different pages and refresh to ensure routes work.
Data loads correctly
Data loads correctly
Verify data fetching from Supabase works as expected.
No console errors
No console errors
Open browser DevTools and check for errors or warnings.
Troubleshooting
Build fails
- Check TypeScript errors:
npm run buildlocally - Verify all dependencies are installed
- Ensure Node.js version matches (18+)
Environment variables not working
- Verify variables start with
VITE_ - Rebuild after adding new variables
- Check they’re set in the hosting platform
Routes return 404
- Add SPA redirect rules (
_redirectsor nginx config) - Verify output directory is set to
dist
Supabase connection fails
- Check production URLs are added to Supabase
- Verify environment variables are correct
- Test connection locally with production credentials
Next steps
API Reference
Explore the Goalst API documentation
Authentication
Learn about authentication setup