Appearance
Deploy to Vercel
Vercel is the recommended deployment platform for Portfolio CMS. It provides seamless integration with Next.js and easy configuration.
Prerequisites
- GitHub account with your code pushed
- Vercel account (vercel.com)
- PostgreSQL database ready
- S3 storage configured
Step-by-Step Deployment
Step 1: Connect Repository
- Go to vercel.com/new
- Click "Import Git Repository"
- Select your GitHub repository
- Click "Import"
Step 2: Configure Project
Vercel will auto-detect Next.js. Verify settings:
| Setting | Value |
|---|---|
| Framework Preset | Next.js |
| Root Directory | ./ |
| Build Command | pnpm ci:build |
| Output Directory | .next |
| Install Command | pnpm install |
Step 3: Add Environment Variables
Click "Environment Variables" and add:
env
DATABASE_URL=postgresql://user:password@host:5432/database?sslmode=require
PAYLOAD_SECRET=your-super-secret-key-at-least-32-characters
NEXT_PUBLIC_SITE_URL=https://your-project.vercel.app
S3_BUCKET=your-bucket-name
S3_ACCOUNT_ID=your-account-id
S3_ACCESS_KEY_ID=your-access-key
S3_SECRET=your-secret-key
# Optional
RESEND_API_KEY=re_...
RESEND_FROM_EMAIL=...
RESEND_FROM_NAME=...Important
Use your actual production values, not development placeholders.
Step 4: Deploy
- Click "Deploy"
- Wait for build to complete (3-5 minutes)
- Your site is live!
Using Vercel Postgres
Vercel offers integrated PostgreSQL:
Setup
- Go to your project's Storage tab
- Click "Create Database" > "Postgres"
- Follow the setup wizard
- Environment variables are auto-added
Connection String
Vercel Postgres uses POSTGRES_URL by default. Update your config if needed:
env
DATABASE_URL=${POSTGRES_URL}Or update payload.config.ts:
typescript
db: postgresAdapter({
pool: {
connectionString: process.env.POSTGRES_URL || process.env.DATABASE_URL,
},
}),Custom Domain
Adding a Domain
- Go to Project Settings > Domains
- Enter your domain name
- Click "Add"
DNS Configuration
Add these records at your registrar:
For apex domain (example.com):
Type: A
Name: @
Value: 76.76.21.21For www subdomain:
Type: CNAME
Name: www
Value: cname.vercel-dns.comSSL Certificate
Vercel automatically provisions SSL certificates. No configuration needed.
Build Configuration
Build Command Options
Standard build:
bash
pnpm buildWith migrations:
bash
payload migrate && pnpm buildCI-specific script:
bash
pnpm ci:buildEnvironment-Specific Builds
Create different environments in Vercel:
- Production: Main branch
- Preview: Pull requests
- Development: Dev branch
Each can have different environment variables.
Deployment Settings
Automatic Deployments
By default, Vercel deploys:
- Every push to main branch
- Every pull request (preview)
Disable Automatic Deployments
If needed:
- Project Settings > Git
- Toggle off "Auto-Deployments"
Ignored Build Step
Skip builds for certain files:
bash
# vercel-ignore-build-step.sh
if [[ "$VERCEL_GIT_COMMIT_MESSAGE" == *"[skip ci]"* ]]; then
echo "Skipping build"
exit 0
fi
exit 1Troubleshooting
Build Fails
Check build logs:
- Go to Deployments tab
- Click failed deployment
- View build logs
Common issues:
bash
# TypeScript errors
Error: Type error: ...
# Fix: Run locally first
pnpm typecheck
pnpm generate:typesbash
# Memory issues
FATAL ERROR: Reached heap limit
# Fix: Add to build command
NODE_OPTIONS="--max-old-space-size=4096" pnpm buildbash
# Missing environment variables
Error: Missing required environment variable
# Fix: Check all env vars are set in Vercel dashboardDatabase Connection Failed
- Check
DATABASE_URLis correct - Verify database is accessible
- Check SSL mode (
?sslmode=require) - Whitelist Vercel IPs if needed
Images Not Loading
- Verify S3 credentials
- Check CORS configuration
- Ensure bucket exists
- Check file permissions
Admin Panel 404
- Ensure build completed successfully
- Check for errors in function logs
- Verify Payload routes are correct
Performance Optimization
Edge Functions
For faster response times:
typescript
// next.config.mjs
export default {
experimental: {
runtime: 'edge',
},
}Image Optimization
Vercel automatically optimizes images. Ensure:
- Images use
next/image - Proper sizing configured
- Domains whitelisted
Caching
Configure cache headers:
typescript
// next.config.mjs
export default {
headers: async () => [
{
source: '/:path*',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=31536000, immutable',
},
],
},
],
}Monitoring
Vercel Analytics
Enable in Project Settings:
- Web Analytics: Page views, visitors
- Speed Insights: Core Web Vitals
Logs
View function logs:
- Go to Deployments
- Select deployment
- Click "Functions" tab
- View real-time logs
Alerts
Set up deployment notifications:
- Project Settings > Notifications
- Configure Slack, Discord, or email alerts