Overview
jøsh is designed to be deployed on Vercel, taking advantage of serverless functions, edge networking, and seamless Next.js integration.Prerequisites
Before deploying, ensure you have:- A Vercel account (sign up here)
- A PostgreSQL database (Supabase, Neon, Railway, etc.)
- All required environment variables configured
- Git repository connected to Vercel
Deployment Methods
Method 1: Vercel Git Integration (Recommended)
Connect your repository
- Log in to Vercel
- Click “Add New Project”
- Import your Git repository (GitHub, GitLab, or Bitbucket)
- Select the repository containing jøsh
Configure project settings
Vercel will auto-detect Next.js. Verify the following settings:
| Setting | Value |
|---|---|
| Framework Preset | Next.js |
| Build Command | npm run vercel-build |
| Output Directory | .next |
| Install Command | npm install |
The
vercel-build script runs prisma generate && next build to ensure Prisma client is generated before building.Add environment variables
In the Vercel project settings, navigate to Environment Variables and add:
DATABASE_URLDIRECT_URLAI_GATEWAY_API_KEYSURGE_API_KEYSURGE_ACCOUNT_IDSURGE_WEBHOOK_SECRETSUPABASE_PROJECT_URLSUPABASE_SERVICE_ROLE_KEYSUPABASE_UPLOAD_BUCKETMUTUAL_INTERNAL_API_KEY
Method 2: Vercel CLI
Deploy directly from your local machine using the Vercel CLI.Database Migrations
Initial Setup
After your first deployment, run database migrations:Subsequent Migrations
When updating the database schema:-
Development: Create and test migrations locally
-
Production: Deploy schema changes
For zero-downtime deployments with schema changes, consider using Prisma’s expand/contract pattern.
Build Configuration
Custom Build Script
Thevercel-build script ensures Prisma client generation before build:
package.json
PostHog Integration
The application includes PostHog analytics with custom rewrites for first-party data collection:next.config.ts
These rewrites proxy PostHog requests through your domain, improving data collection reliability.
Environment-Specific Configuration
Vercel supports multiple environments:- Production: Deployed from
main/masterbranch - Preview: Deployed from pull requests and other branches
- Development: Local environment
| Environment | Use Case |
|---|---|
| Production | Live production deployment |
| Preview | Staging/testing for pull requests |
| Development | Local development (use .env file) |
Monitoring & Debugging
Vercel Logs
View deployment logs and runtime errors:- Navigate to your project in Vercel
- Click “Deployments”
- Select a deployment
- View Build Logs and Function Logs
Common Deployment Issues
Prisma Client Not Found
Cause: Prisma client not generated during build Solution: Ensurevercel-build script includes prisma generate
Database Connection Errors
Cause: IncorrectDATABASE_URL or connection pooling issues
Solution:
- Verify
DATABASE_URLformat - Use connection pooling URL for
DATABASE_URL - Use direct connection URL for
DIRECT_URL
Environment Variables Not Available
Cause: Variables not set in Vercel dashboard Solution: Add missing variables in Project Settings → Environment VariablesContinuous Deployment
With Vercel Git integration, deployments are automatic:- Push to branch → Creates preview deployment
- Merge to main → Deploys to production
- Open pull request → Generates preview URL
Deployment Protection
Enable deployment protection for production:- Go to Project Settings → Deployment Protection
- Enable Vercel Authentication for production
- Restrict access to team members only
Performance Optimization
Image Optimization
jøsh uses Next.js Image optimization with configured remote patterns:next.config.ts
Caching Strategy
Vercel automatically caches:- Static assets (images, CSS, JS)
- API responses with proper cache headers
- Edge functions for low-latency responses
Rollback & Version Control
Rollback to a previous deployment:- Navigate to Deployments in Vercel
- Find the stable deployment
- Click ”…” → “Promote to Production”
Instant rollback allows you to revert to any previous deployment without redeploying code.
Custom Domains
Add a custom domain to your Vercel deployment:Configure DNS
Add the DNS records provided by Vercel:
| Type | Name | Value |
|---|---|---|
| A | @ | 76.76.21.21 |
| CNAME | www | cname.vercel-dns.com |
Webhooks & API Routes
Surge SMS Webhook
Configure your Surge webhook URL to point to your production deployment:Update webhook URLs in your Surge SMS dashboard after each domain change.
Security Considerations
Environment variable security
- Use Vercel’s encrypted environment variables
- Never commit secrets to Git
- Rotate API keys regularly
Next Steps
Local Setup
Set up jøsh locally for development
Environment Variables
Configure required environment variables