Prerequisites
- GitHub account with your Hiro CRM repository
- Vercel account (free tier works)
- Supabase project set up (see Database Setup)
- Environment variables ready (see Environment Variables)
Deployment Steps
Import project to Vercel
- Go to Vercel Dashboard
- Click Add New → Project
- Import your Git repository
- Select the repository containing Hiro CRM
Configure project settings
In the import wizard, configure the following:Framework Preset: Next.js (auto-detected)Root Directory:
frontendBuild Command: npm run build (default)Output Directory: .next (default)Install Command: npm install (default)Add environment variables
Before deploying, add all required environment variables:
- In the Vercel import wizard, expand Environment Variables
- Add each variable from your
.env.localfile
Required Variables
Required Variables
Optional Variables
Optional Variables
Add any optional integrations you need:
OPENAI_API_KEY- AI AssistantBREVO_API_KEY,BREVO_SENDER_EMAIL, etc. - Email campaignsSENTRY_DSN- Error trackingCOVERMANAGER_API_KEYorREVO_ACCESS_TOKEN- POS integration
You can also add environment variables after deployment in Project Settings → Environment Variables.
Deploy
Click Deploy and wait for the build to complete.Vercel will:
- Clone your repository
- Install dependencies (
npm install) - Run the build (
npm run build) - Deploy to a production URL
Custom Domain Setup
Add your own domain to your Vercel deployment.Add domain in Vercel
- Go to Project Settings → Domains
- Click Add
- Enter your domain (e.g.,
crm.your-restaurant.com) - Click Add
Configure DNS
Vercel will provide DNS configuration instructions:Option A: CNAME (recommended for subdomains)Option B: A Record (for apex domains)Add these records in your domain registrar’s DNS settings.
Update NEXT_PUBLIC_APP_URL
After domain is configured, update the environment variable:
- Go to Project Settings → Environment Variables
- Edit
NEXT_PUBLIC_APP_URL - Change to your custom domain:
https://crm.your-restaurant.com - Redeploy for changes to take effect
Vercel Configuration Files
Hiro CRM includes two Vercel configuration files:Root vercel.json
Configures cron jobs for automated tasks:vercel.json
sync- Daily at 8:00 AM (UTC) - Syncs POS datacalendar-notifications- Daily at 9:00 AM - Sends calendar notificationscalendar-reminders- Daily at 8:00 AM - Sends calendar remindersticket-notifications- Daily at 10:00 AM - Sends ticket notificationsticket-reminders- Daily at 8:00 AM - Sends ticket remindersautomations- Every 30 minutes - Runs marketing automations
Frontend vercel.json
Configures the master cron job:frontend/vercel.json
The master cron job runs daily at 8:00 AM UTC and can trigger multiple background tasks.
Next.js Configuration
Key configurations innext.config.ts:
Standalone Output
Security Headers
Production-grade security headers are automatically configured:- X-Frame-Options:
DENY- Prevents clickjacking - X-Content-Type-Options:
nosniff- Prevents MIME sniffing - Referrer-Policy:
strict-origin-when-cross-origin - Permissions-Policy: Restricts camera, microphone, geolocation
- Content-Security-Policy: Comprehensive CSP for XSS protection
- HSTS: Strict-Transport-Security (production only)
Image Optimization
Configured domains for Next.js Image optimization:*.supabase.co- Supabase Storageimages.unsplash.com- Demo images
Performance Optimizations
- Tree-shaking: Optimized imports for
lucide-react,framer-motion,recharts,date-fns - Compression: Gzip enabled
- Server External Packages:
@supabase/supabase-jsfor better performance
CI/CD Workflow
Vercel automatically deploys on Git push.Automatic Deployments
- Production
- Preview
Trigger: Push to
main branchURL: Your production domain (e.g., crm.your-restaurant.com)Environment: Production environment variablesCron Jobs: Enabled (Pro plan only)Deployment Protection
Enable deployment protection for production:- Go to Project Settings → Deployment Protection
- Enable Vercel Authentication to require login to access deployments
- Add specific email addresses or enable SSO (Team plans)
Monitoring & Debugging
View Logs
- Go to your project in Vercel Dashboard
- Click on a deployment
- View Build Logs and Function Logs
Real-time Logs
Stream function logs in real-time:Analytics
Vercel provides built-in analytics:- Web Analytics: Page views, visitors, top pages
- Speed Insights: Real User Monitoring (RUM) performance data
Hiro CRM already includes Vercel Analytics and Speed Insights in the code. No additional setup needed.
Troubleshooting
Build fails with 'Module not found'
Build fails with 'Module not found'
Cause: Incorrect root directory setting.Solution:
- Go to Project Settings → General
- Set Root Directory to
frontend - Redeploy
Environment variables not working
Environment variables not working
Cause: Variables not properly set or not redeployed after changes.Solution:
- Verify variables in Project Settings → Environment Variables
- Make sure
NEXT_PUBLIC_prefix is used for client-side variables - Redeploy after adding/changing variables
Cron jobs not running
Cron jobs not running
Cause: Cron jobs require a Pro plan or higher.Solution:
- Upgrade to Vercel Pro, or
- Use an external cron service (e.g., cron-job.org) to call your API endpoints
Images not loading
Images not loading
Cause: Domain not configured in
next.config.ts.Solution:
Add the image domain to remotePatterns in next.config.ts:502 Bad Gateway on API routes
502 Bad Gateway on API routes
Cause: Function timeout (10s on Hobby, 60s on Pro).Solution:
- Optimize slow database queries
- Consider background jobs for long-running tasks
- Upgrade to Pro for 60s timeout
Performance Optimization
Enable Edge Config (Pro/Enterprise)
Store configuration that needs to be globally available with ultra-low latency:Enable Edge Middleware
Hiro CRM’smiddleware.ts runs on Vercel Edge Network for:
- Authentication checks
- Redirects
- International routing
Already configured and optimized!
Optimize Bundle Size
Monitor your bundle size:Security Checklist
Review environment variables
Ensure no secrets are exposed in client-side variables (without
NEXT_PUBLIC_ prefix).Next Steps
Database Setup
Configure your Supabase database
Seeding Data
Add demo data to your database
Environment Variables
Complete environment variable reference
Vercel Docs
Official Vercel documentation
