Prerequisites
Before deploying to Vercel:Prepare Database
Provision a PostgreSQL database (recommended: Neon) and obtain the connection string. See Database Setup.
Configure Environment Variables
Prepare all required environment variables. See Environment Variables.
Create Vercel Account
Sign up at vercel.com if you don’t have an account.
Deployment Methods
- Git Integration (Recommended)
- Vercel CLI
Deploy automatically from your Git repository:
Connect Repository
- Go to vercel.com/new
- Import your Git repository (GitHub, GitLab, or Bitbucket)
- Select the repository containing Featul
Configure Project
Vercel auto-detects Next.js settings:
- Framework Preset: Next.js
- Root Directory:
apps/app - Build Command:
cd ../.. && bun run build --filter=app - Output Directory:
apps/app/.next - Install Command:
bun install
Set Environment Variables
Add all environment variables from Environment Variables:
Vercel Configuration
Featul includes avercel.json configuration file:
- Use Bun 1.x for package installation (faster than npm/pnpm)
- Follow the OpenAPI schema for validation
Project Settings
Recommended Vercel project settings:Build Settings
- Framework: Next.js
- Node.js Version: 20.x
- Package Manager: Bun
- Build Command:
cd ../.. && bun run build --filter=app
Performance
- Edge Middleware: Enabled (for subdomain routing)
- Image Optimization: Enabled
- Caching: Default Next.js caching
- Compression: Enabled
Domain Configuration
Add Custom Domain
Add Root Domain
In Vercel project settings:
- Go to Settings > Domains
- Add your root domain:
yourdomain.com - Vercel provides DNS records to configure
Configure DNS
Add these records to your DNS provider:The wildcard
* CNAME enables workspace subdomains:workspace1.yourdomain.comworkspace2.yourdomain.com- etc.
Add Subdomains
In Vercel, add:
app.yourdomain.com(main application)*.yourdomain.com(wildcard for workspaces)
Update Environment Variables
After adding custom domain, update:Database Migrations
Run database migrations before first deployment:Migrations must be run manually before deployment. Vercel builds don’t automatically run migrations.
Automated Migrations (Optional)
To run migrations on every deployment, add a build hook:- Update
package.jsonbuild script:
- Ensure
DATABASE_URLis available at build time:- Vercel: Add
DATABASE_URLto environment variables - Check “Expose to build” option
- Vercel: Add
Environment-Specific Configuration
Configure different settings for Production, Preview, and Development:- Production
- Preview (Staging)
- Development
Monitoring and Analytics
Vercel Analytics
Enable built-in analytics:- Go to Analytics tab in Vercel dashboard
- Enable Web Analytics
- Add to
apps/app/app/layout.tsx:
Sentry Integration
Featul includes Sentry pre-configured innext.config.ts:
- Uploads source maps during build
- Tracks errors and performance
- Links deployments to Sentry releases
Performance Monitoring
Vercel provides:- Speed Insights: Real user metrics (Core Web Vitals)
- Logs: Runtime logs for API routes and functions
- Real-time events: Live deployment and request logs
Optimization Tips
Enable Edge Runtime for Middleware
Middleware (
apps/app/src/middleware.ts) automatically runs on Vercel Edge for fast subdomain routing.CI/CD Workflow
Vercel automatically deploys:- Production: Commits to
mainbranch →app.yourdomain.com - Preview: Pull requests → Unique preview URL
- Development: Other branches → Preview deployments
GitHub Integration Features
- Deployment status checks on PRs
- Preview deployment comments on PRs
- Automatic rollbacks on failed deployments
- Branch protection integration
Troubleshooting
Build Fails: “Command not found”
vercel.json specifies bunVersion:
Runtime Error: “DATABASE_URL not set”
Solution:- Verify environment variable is set in Vercel
- Check it’s enabled for Production environment
- Redeploy after adding variable
Subdomain Not Working
Solution:- Verify wildcard DNS record:
CNAME * cname.vercel-dns.com - Add
*.yourdomain.comin Vercel domains - Wait for DNS propagation (up to 48 hours)
- Test with:
dig workspace.yourdomain.com
OAuth Redirect Error
- Google:
https://app.yourdomain.com/api/auth/callback/google - GitHub:
https://app.yourdomain.com/api/auth/callback/github
Next Steps
Environment Variables
Complete environment variable reference
Database Setup
Configure and migrate your database
Cloudflare Deployment
Alternative deployment to Cloudflare