Deployment
Deploy your Craft projects to production and share them with the world. This guide covers deployment options, configuration, and best practices.
Deployment Options#
Vercel (Recommended)#
The easiest option for Next.js applications.
Benefits:
- Zero configuration deployment
- Automatic SSL
- Global CDN
- Preview deployments
- Easy environment variables
Other Platforms#
Craft projects work with any Next.js-compatible host:
- Netlify - Similar to Vercel
- Railway - Great for full-stack apps
- AWS Amplify - AWS ecosystem integration
- Cloudflare Pages - Edge performance
Deploying to Vercel#
Quick Deploy#
- Open Project Settings
- Click Deploy
- Connect your Vercel account
- Configure settings
- Click Deploy
Manual Deploy#
Export and deploy manually:
- Export project from Craft
- Push to GitHub/GitLab
- Import in Vercel dashboard
- Configure environment variables
- Deploy
Environment Variables#
Set production variables in Vercel:
- Go to Project Settings
- Navigate to Environment Variables
- Add your variables
- Select environments (Production, Preview, Development)
Pre-Deployment Checklist#
Code Quality#
- [ ] No console.log statements in production code
- [ ] Error boundaries in place
- [ ] Loading states implemented
- [ ] Form validation working
Performance#
- [ ] Images optimized
- [ ] Fonts properly loaded
- [ ] No unnecessary dependencies
- [ ] Code splitting implemented
Security#
- [ ] Environment variables set
- [ ] No secrets in code
- [ ] HTTPS enforced
- [ ] Input validation in place
SEO#
- [ ] Meta tags configured
- [ ] Open Graph images
- [ ] Sitemap generated
- [ ] robots.txt in place
Domain Configuration#
Custom Domain#
- Go to Vercel project settings
- Navigate to Domains
- Add your domain
- Configure DNS records
DNS Setup#
Add these records at your DNS provider:
| Type | Name | Value | | ----- | ---- | -------------------- | | A | @ | 76.76.21.21 | | CNAME | www | cname.vercel-dns.com |
SSL Certificate#
Vercel automatically provisions SSL certificates. No action required!
Deployment Configuration#
Build Settings#
Configure in next.config.ts:
const nextConfig = {
output: "standalone", // For Docker deployments
images: {
domains: ["your-image-domain.com"],
},
};
Environment-Specific Config#
const isProd = process.env.NODE_ENV === "production";
const config = {
apiUrl: isProd ? "https://api.production.com" : "http://localhost:3001",
};
Continuous Deployment#
GitHub Integration#
Every push to main automatically deploys:
- Connect GitHub repository
- Configure branch settings
- Enable automatic deployments
Preview Deployments#
Pull requests get unique preview URLs:
- Test changes before merging
- Share for review
- Automatic cleanup
Monitoring#
Vercel Analytics#
Built-in analytics for:
- Page views
- Web Vitals
- Error tracking
Enable in project settings.
Error Tracking#
Recommended services:
- Sentry - Detailed error reports
- LogRocket - Session replay
- Datadog - Full observability
Troubleshooting#
Build Failures#
Common issues:
-
Missing environment variables
- Add all required variables in Vercel
-
TypeScript errors
- Fix type errors locally first
- Check strict mode settings
-
Dependency issues
- Clear node_modules and reinstall
- Check for version conflicts
Runtime Errors#
- Check Vercel function logs
- Review error messages
- Test locally with production build:
npm run build
npm start
Performance Issues#
- Analyze with Lighthouse
- Check bundle size
- Review Core Web Vitals
- Optimize images and fonts
Rollback#
Quick Rollback#
In Vercel dashboard:
- Go to Deployments
- Find the previous working deployment
- Click the three dots menu
- Select "Promote to Production"
Automatic Rollback#
Configure in project settings for automatic rollback on errors.
Best Practices#
Use Preview Deployments#
- Test all changes in preview
- Share preview links for review
- Don't skip to production
Monitor After Deploy#
- Watch error rates
- Check performance metrics
- Monitor user feedback
Keep Dependencies Updated#
- Regular security updates
- Performance improvements
- New features
Document Deployment Process#
- Environment variables needed
- Configuration requirements
- Rollback procedures
Next Steps#
- Environment Variables - Production config
- Database Integration - Database deployment
- Best Practices - Production tips