Deploy to Vercel
Deploy Umami to Vercel’s serverless platform for automatic scaling and global CDN distribution.Prerequisites
Vercel is a serverless platform optimized for Next.js applications. It provides:
- Automatic deployments from Git
- Global CDN
- Automatic HTTPS
- Environment variable management
- Free tier for hobby projects
Quick Deploy
Set Up PostgreSQL Database
Before deploying to Vercel, create a PostgreSQL database:
- Supabase (Recommended)
- Neon
- Railway PostgreSQL
- Go to supabase.com
- Create a free account
- Create a new project
- Wait for database provisioning
- Go to Settings → Database
- Copy the Connection String (URI format)
Fork the Repository
Fork Umami to your GitHub account:
- Go to github.com/umami-software/umami
- Click Fork button
- Choose your account
Configure Environment Variables
Add environment variables in Vercel:Make sure to add variables for all environments:
- In the import screen, expand Environment Variables
- Add the following:
- Production
- Preview
- Development (optional)
Deploy
- Click Deploy
- Vercel will build and deploy Umami
- Wait for deployment to complete (2-5 minutes)
- Click Visit to open your Umami instance
Initialize Database
On first deployment, you need to initialize the database:
- Automatic (Recommended)
- Manual Migration
The build process should automatically create tables:
- Check deployment logs for database migration
- If successful, tables are created automatically
Custom Domain Setup
Add your own domain to Vercel:Add Domain in Vercel
- Go to your project in Vercel
- Click Settings tab
- Click Domains in sidebar
- Enter your domain (e.g.,
analytics.yourdomain.com) - Click Add
Configure DNS
Vercel will show you DNS records to add:
- Subdomain (CNAME)
- Root Domain (A)
For subdomains like
analytics.yourdomain.com:Environment Variables
Configure Umami on Vercel:Required Variables
Required Variables
Optional Variables
Optional Variables
Update Environment Variables
- Go to Settings → Environment Variables
- Click Edit on the variable
- Update the value
- Click Save
- Redeploy for changes to take effect
Database Configuration
Connection Pooling
Vercel serverless functions create many database connections. Use connection pooling to avoid “too many connections” errors.
- Supabase
- Neon
- PgBouncer
Use the connection pooling endpoint:
Database Performance
Build Configuration
Build Settings
Vercel auto-detects Next.js projects. Default settings:Custom Build Settings
Override invercel.json:
vercel.json
Deployment Settings
Auto-Deploy from Git
Vercel automatically deploys:- Production: Pushes to
mainbranch - Preview: Pushes to other branches or pull requests
Disable Auto-Deploy
- Go to Settings → Git
- Toggle Production Branch or Preview Branches
- Click Save
Monitoring and Logs
View Logs
- Go to your project dashboard
- Click on a deployment
- View:
- Build Logs: Compilation output
- Function Logs: Runtime logs
- Error Logs: Runtime errors
Real-time Logs
Use Vercel CLI:Analytics
Enable Vercel Analytics:- Go to Analytics tab
- Click Enable Analytics
- View:
- Pageviews
- Top pages
- Top referrers
- Device breakdown
Vercel Analytics is separate from Umami. Umami tracks your websites, while Vercel Analytics tracks the Umami dashboard itself.
Troubleshooting
Build fails with database error
Build fails with database error
The build process needs DATABASE_URL:
- Go to Settings → Environment Variables
- Ensure
DATABASE_URLis set for all environments - Redeploy
- Run migrations manually (see Initialize Database step)
- Check database connection from your local machine
Too many database connections
Too many database connections
Enable connection pooling:
- Use Supabase pooler (port 6543)
- Use Neon (built-in pooling)
- Set up PgBouncer
- Reduce concurrent function executions
Function timeout errors
Function timeout errors
Vercel has execution limits:
- Hobby: 10 seconds
- Pro: 60 seconds
- Enterprise: 900 seconds
- Upgrade to Pro for longer timeouts
- Optimize slow database queries
- Use background jobs for long tasks
Deployment stuck or failed
Deployment stuck or failed
Check deployment logs:
- Click on failed deployment
- View build logs for errors
- Common issues:
- Missing environment variables
- Database connection failed
- Build errors in code
- Out of memory
- Redeploy
- Clear build cache: Settings → General → Clear Cache
- Check Vercel status page
App is slow
App is slow
Optimize performance:
- Use connection pooling
- Add database indexes
- Enable Redis caching (if using REDIS_URL)
- Upgrade to Pro for better resources
- Use ClickHouse for high-volume analytics
Updating Umami
Auto-Deploy
Vercel automatically deploys when you push to main:
- Watch deployment progress in Vercel dashboard
- Database migrations run automatically
- New version is live when deployment completes
Best Practices
Use Connection Pooling
Prevents “too many connections” errors in serverless environment
Enable Preview Deployments
Test changes in preview URLs before merging to production
Set Up Database Backups
Regularly backup your PostgreSQL database
Monitor Function Usage
Track Vercel usage to avoid hitting free tier limits
Cost Optimization
Stay within Vercel’s free tier:- Free tier: Unlimited for personal projects with usage limits
- Pro: $20/month per member (better limits)
- Enterprise: Custom pricing
- Use efficient database queries
- Enable caching where possible
- Monitor function execution time
- Optimize images and assets
- Consider upgrading for high-traffic sites
Next Steps
Add Website
Start tracking your first website
Configure Variables
Set up advanced features
Database Optimization
Optimize PostgreSQL performance
Custom Domain
Set up your own domain