First Deployment
This guide walks you through deploying your Ever Works to production for the first time.
Pre-Deployment Checklist
Before deploying, ensure you have:
- Completed environment setup
- Tested locally with
npm run dev - Set up your data repository
- Configured at least one authentication provider
- Generated production secrets
- Prepared your domain (if using custom domain)
Deployment Options
Option 1: Vercel (Recommended)
Vercel provides the best experience for Next.js applications.
1. Install Vercel CLI
npm install -g vercel
2. Login to Vercel
vercel login
3. Deploy
vercel
Follow the prompts:
- Link to existing project? No
- Project name:
your-project-name - Directory:
./(current directory) - Override settings? No
4. Set Environment Variables
In the Vercel dashboard:
- Go to your project → Settings → Environment Variables
- Add all production environment variables
- Set different values for Production, Preview, and Development
Critical Production Variables:
NODE_ENV=production
NEXTAUTH_URL=https://your-domain.vercel.app
NEXT_PUBLIC_APP_URL=https://your-domain.vercel.app
AUTH_SECRET=your-production-secret
DATABASE_URL=your-production-database-url
5. Redeploy
vercel --prod
Option 2: Netlify
1. Build Settings
Create netlify.toml:
[build]
command = "npm run build"
publish = ".next"
[build.environment]
NODE_VERSION = "20"
[[redirects]]
from = "/*"
to = "/index.html"
status = 200
2. Deploy
Connect your GitHub repository to Netlify and configure build settings.
Option 3: Railway
1. Install Railway CLI
npm install -g @railway/cli
2. Login and Deploy
railway login
railway init
railway up
Option 4: DigitalOcean App Platform
- Connect your GitHub repository
- Configure build settings:
- Build command:
npm run build - Run command:
npm start
- Build command:
- Set environment variables
- Deploy
Database Setup
Option 1: Supabase (Recommended)
- Create project at Supabase
- Get connection string from Settings → Database
- Run migrations:
# Set DATABASE_URL to your Supabase connection string
npm run db:migrate
npm run db:seed
Option 2: PlanetScale
- Create database at PlanetScale
- Get connection string
- Run migrations
Option 3: Neon
- Create database at Neon
- Get connection string
- Run migrations
Domain Configuration
Custom Domain on Vercel
- Go to project → Settings → Domains
- Add your domain
- Configure DNS records:
- Type:
CNAME - Name:
@(or subdirectory) - Value:
cname.vercel-dns.com
- Type:
SSL Certificate
SSL is automatically provided by most platforms. Verify HTTPS is working.
OAuth Configuration
Update your OAuth applications with production URLs:
Google OAuth
- Authorized JavaScript origins:
https://yourdomain.com - Authorized redirect URIs:
https://yourdomain.com/api/auth/callback/google
GitHub OAuth
- Homepage URL:
https://yourdomain.com - Authorization callback URL:
https://yourdomain.com/api/auth/callback/github
Stripe Webhooks
- Endpoint URL:
https://yourdomain.com/api/stripe/webhook - Events:
checkout.session.completed,invoice.payment_succeeded
Post-Deployment Verification
1. Basic Functionality
- Homepage loads correctly
- Items display properly
- Search and filtering work
- Navigation functions
2. Authentication
- Sign in with configured providers
- User profiles are created
- Sessions persist correctly
- Sign out works
3. Content Management
- Content syncs from Git repository
- New submissions create pull requests
- Admin panel accessible (if configured)
4. Payment Processing (if configured)
- Checkout flow works
- Webhooks receive events
- Subscriptions are created
- Customer portal accessible
5. Performance
- Page load times < 3 seconds
- Images load properly
- No console errors
- Mobile responsiveness
Monitoring Setup
1. Error Tracking
Verify Sentry is receiving errors:
# Test error tracking
curl -X POST https://yourdomain.com/api/test-error
2. Analytics
Verify PostHog is tracking events:
- Check PostHog dashboard for page views
- Test custom events
- Verify user identification
3. Uptime Monitoring
Set up monitoring with:
Performance Optimization
1. Enable Caching
Ensure these headers are set:
// next.config.js
module.exports = {
async headers() {
return [
{
source: '/api/:path*',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=300, stale-while-revalidate=60'
}
]
}
]
}
}
2. Image Optimization
Verify Next.js image optimization is working:
- Images are served in WebP format
- Proper sizing for different devices
- Lazy loading is enabled
3. Bundle Analysis
Analyze your bundle size:
npm run build
npm run analyze
Security Checklist
- HTTPS enabled
- Secure cookies in production
- CORS properly configured
- Rate limiting enabled
- Input validation working
- SQL injection protection
- XSS protection enabled
Backup Strategy
1. Database Backups
Set up automated backups:
- Daily database snapshots
- Point-in-time recovery
- Cross-region replication
2. Content Backups
Your content is already backed up in Git, but consider:
- Regular repository backups
- Multiple remote repositories
- Automated sync verification
Rollback Plan
Prepare for issues:
- Keep previous deployment available
- Database migration rollback scripts
- DNS failover configuration
- Monitoring alerts for critical issues