Prerequisites
Before deploying to Vercel, ensure you have:- A Vercel account (sign up for free)
- Your code in a Git repository (GitHub, GitLab, or Bitbucket)
- Supabase project URL and anon key
- All required environment variables ready
Deployment steps
Connect your repository
- Log in to Vercel
- Click “Add New…” > “Project”
- Choose your Git provider (GitHub, GitLab, or Bitbucket)
- Authorize Vercel to access your repositories
- Select the DoctorSoft+ repository
- Click “Import”
Configure project settings
Vercel will automatically detect the framework and configure build settings:
| Setting | Value |
|---|---|
| Framework Preset | Vite |
| Build Command | npm run build |
| Output Directory | dist |
| Install Command | npm install |
Vercel automatically detects Vite projects and configures optimal settings. You typically don’t need to change these.
Add environment variables
Before deploying, add all required environment variables:
- In the project configuration screen, expand “Environment Variables”
- Add the following required variables:
- Select which environments each variable applies to:
- Production: Live site
- Preview: Pull request deployments
- Development: Local development (optional)
Deploy
- Click “Deploy”
- Vercel will clone your repository and start the build process
- Monitor the build logs in real-time
- Once complete, your site will be live at a Vercel subdomain (e.g.,
doctorsoft-plus.vercel.app)
Environment variable configuration
If you need to add or update environment variables after deployment:Navigate to project settings
- Go to your project in the Vercel dashboard
- Click “Settings”
- Navigate to “Environment Variables”
Add or edit variables
- Enter the variable name and value
- Select which environments it applies to:
- Production
- Preview
- Development
- Click “Save”
Environment scopes
Vercel allows you to set environment variables for different contexts:- Production: Used for your production domain deployments
- Preview: Used for pull request and branch preview deployments
- Development: Available when using
vercel devlocally
It’s recommended to set the same values for Production and Preview to ensure consistency across environments.
SPA routing configuration
DoctorSoft+ is a single-page application that uses client-side routing. Vercel automatically handles SPA routing for Vite projects, but you can customize this behavior if needed.Automatic routing
Vercel automatically configures rewrites for SPA applications. No additional configuration is required.Custom configuration (optional)
If you need custom routing rules, create avercel.json file in your repository root:
The
vercel.json file is optional. Vercel’s automatic detection works well for most Vite applications.Continuous deployment
Vercel automatically deploys your site whenever you push to your repository:- Production deployments: Every push to the main/master branch creates a production deployment
- Preview deployments: Pull requests and other branches get unique preview URLs
- Instant rollbacks: Quickly rollback to any previous deployment with one click
Preview deployments
Every pull request automatically gets a preview deployment:- Unique URL for each PR (e.g.,
doctorsoft-plus-git-feature-branch.vercel.app) - Automatically updated when new commits are pushed
- Comment on PR with deployment URL and status
- Perfect for testing changes before merging
Deployment notifications
Configure notifications for deployment events:- Go to Project Settings > Notifications
- Connect integrations:
- Slack
- Discord
- GitHub (automatic PR comments)
Monitoring and analytics
Deployment logs
To view deployment logs:- Go to the “Deployments” tab
- Click on any deployment
- View real-time build logs
- Check runtime logs for your deployment
Vercel Analytics
Enable Vercel Analytics to monitor performance:- Go to your project dashboard
- Click “Analytics”
- Enable analytics
- View metrics:
- Real user monitoring (Core Web Vitals)
- Page load times
- Geographic distribution
- Top pages and routes
Speed Insights
Enable Speed Insights for detailed performance data:- Go to Project Settings > Speed Insights
- Enable Speed Insights
- Add the analytics script to your app (automatic with Vercel)
- Monitor Core Web Vitals and performance scores
Troubleshooting
Build fails with “Error: Command failed”
Common causes:- Missing environment variables
- TypeScript compilation errors
- Dependency installation failures
- Check the build logs for specific error messages
- Verify all required environment variables are set for Production and Preview
- Ensure
package.jsonandpackage-lock.jsonare committed - Try building locally:
npm run build - Check that Node.js version matches (18+)
Blank page after deployment
Common causes:- Missing environment variables
- JavaScript errors in production
- Incorrect build output directory
- Open browser console and check for errors
- Verify all environment variables in Project Settings
- Confirm output directory is set to
dist - Test production build locally:
npm run build && npm run preview - Check deployment logs for warnings
Environment variables not updating
Common causes:- Forgot to redeploy after adding variables
- Variable set for wrong environment (Production vs Preview)
- Browser caching old deployment
- Trigger a new deployment from the Deployments tab
- Verify variable is set for correct environment (Production/Preview/Development)
- Clear browser cache or test in incognito mode
- Check deployment logs to confirm new variables are being used
404 errors on routes
Common causes:- SPA rewrites not configured (rare with Vite auto-detection)
- Custom
vercel.jsonconfiguration error
- Remove custom
vercel.jsonand let Vercel auto-detect - Verify rewrite rules in
vercel.jsonif using custom config - Check deployment configuration in dashboard
- Test routes directly by navigating from home page
Performance optimization
Vercel automatically provides:- Edge Network: Global CDN with 100+ edge locations
- Automatic compression: Brotli and gzip compression
- Smart caching: Intelligent caching based on file types
- HTTP/3: Latest protocol for faster connections
- Image Optimization: Automatic image optimization (when using Vercel Image component)
Additional optimizations
-
Enable Edge Caching:
- Vercel automatically caches static assets at the edge
- Configure custom cache headers via
vercel.json(see above)
-
Use Vercel Analytics:
- Monitor real user performance
- Identify slow pages and optimize accordingly
-
Optimize bundle size:
- Review Vite’s code splitting configuration
- DoctorSoft+ already includes optimized chunk splitting (see
vite.config.ts:36-92)
-
Enable Speed Insights:
- Track Core Web Vitals
- Get actionable performance recommendations
Advanced features
Serverless Functions
If you need backend functionality, Vercel supports serverless functions:- Create an
api/directory in your project root - Add serverless function files (e.g.,
api/hello.ts) - Deploy - functions are automatically detected and deployed
Edge Functions
For ultra-low latency, use Edge Functions:- Create an
edge/directory - Add Edge Function files
- Configure in
vercel.json
Protection
Add password protection or authentication to deployments:- Go to Project Settings > Deployment Protection
- Enable password protection for preview deployments
- Configure Vercel Authentication for production (Pro plan)
Next steps
Environment Variables
Learn about all available environment variables
Deployment Overview
Back to deployment overview
Vercel Documentation
Official Vercel documentation
Analytics & Monitoring
Set up analytics and monitoring