Overview
Vercel is the recommended platform for deploying Trazea. It provides:- Automatic deployments on every git push
- Built-in CI/CD pipeline
- Global CDN for fast content delivery
- Zero-configuration SPA routing
- Environment variable management
Prerequisites
- GitHub, GitLab, or Bitbucket repository with Trazea code
- Vercel account (free tier available)
- Supabase project configured (see Supabase Configuration)
Quick Deploy
1. Connect Repository
- Go to Vercel Dashboard
- Click Add New > Project
- Import your Trazea repository
- Vercel will auto-detect the Vite framework
2. Configure Build Settings
Vercel automatically detects Vite projects. Verify these settings:Should be automatically detected as Vite
3. Add Environment Variables
In the Vercel project settings, add all required environment variables:4. Deploy
Click Deploy and Vercel will:- Install dependencies with
pnpm install - Build the project with
pnpm build - Deploy to global CDN
- Provide a production URL (e.g.,
trazea.vercel.app)
Vercel Configuration
Trazea includes avercel.json configuration file for proper SPA routing:
vercel.json
What This Does
This configuration ensures that all routes (e.g.,/inventario, /spares, /orders) are rewritten to /index.html, allowing React Router to handle client-side routing.
Without this configuration, direct navigation to routes like
/inventario would result in a 404 error.Custom Domain
To use a custom domain:Automatic Deployments
Branch Deployments
Vercel creates preview deployments for every branch:- Production:
mainormasterbranch → production domain - Preview: All other branches → unique preview URL
- PR Comments: Vercel bot comments on pull requests with preview URLs
Deployment Flow
Environment-Specific Variables
Configure different values per environment:Build Optimization
Trazea’s Vite configuration includes production optimizations:vite.config.ts
- react-vendor.js: React and React Router (~150 KB)
- supabase-vendor.js: Supabase client (~180 KB)
- ui-vendor.js: Radix UI and Lucide icons (~120 KB)
- vendor.js: Other dependencies (~200 KB)
Monitoring
Vercel Analytics
Enable Web Analytics in project settings for:- Real-time visitor metrics
- Page performance insights
- Top pages and referrers
Sentry Integration
WithVITE_SENTRY_DSN configured, errors are automatically tracked:
- Unhandled exceptions
- Network failures
- Component errors (via React Error Boundary)
Troubleshooting
404 on Direct Route Access
404 on Direct Route Access
Ensure
vercel.json is present in your repository root with the rewrite configuration.Environment Variables Not Working
Environment Variables Not Working
- Verify variables are prefixed with
VITE_ - Redeploy after adding/changing environment variables
- Check variable scope (Production/Preview/Development)
Build Failures
Build Failures
Check Vercel build logs for:
- TypeScript errors: Run
pnpm buildlocally first - Missing dependencies: Ensure
pnpm-lock.yamlis committed - Node version: Vercel uses Node 22 by default (matches Dockerfile)
Slow Initial Load
Slow Initial Load
Enable Vercel’s Speed Insights to identify bottlenecks:
- Check bundle sizes in build output
- Lazy load routes and components
- Use Vite’s dynamic imports for large features
Production Checklist
Before launching to production:Environment Variables
✓ All production environment variables configured✓ Sentry DSN added for error tracking
Supabase Configuration
✓ Row Level Security enabled on all tables✓ Production Supabase URL configured✓ CORS allowed origins include Vercel domain
Next Steps
Supabase Configuration
Configure authentication, RLS policies, and CORS
Docker Deployment
Alternative deployment using Docker containers