Overview
Vercel provides serverless deployment for both the frontend (React + Vite) and backend (Node.js + Express) components of KAIU Natural Living. The platform automatically handles builds, deployments, and scaling.Prerequisites
Before deploying to Vercel, ensure you have:- A Vercel account (sign up here)
- Your GitHub repository connected to Vercel
- PostgreSQL database (recommend Supabase)
- Redis instance (recommend Upstash)
- All required API keys (see Environment Setup)
Configuration
The project includes avercel.json configuration file that handles API routing:
- Routes all
/api/*requests to the serverless function - Sets a 60-second timeout for API functions (suitable for AI operations)
Deployment Steps
Connect Your Repository
- Go to Vercel Dashboard
- Click “Add New Project”
- Import your Git repository
- Vercel will automatically detect the Vite configuration
Configure Build Settings
Vercel should auto-detect these settings, but verify:
- Framework Preset: Vite
- Build Command:
npm run build - Output Directory:
dist - Install Command:
npm install
Set Environment Variables
Add all required environment variables in the Vercel dashboard:
- Go to Project Settings → Environment Variables
- Add each variable for Production, Preview, and Development environments
- See Environment Setup for the complete list
Deploy
Click “Deploy” and Vercel will:
- Install dependencies
- Run the build process
- Deploy to a production URL
- Provide a deployment summary
Initialize Database
After the first deployment, initialize your database:
Make sure your
DATABASE_URL environment variable points to your production database.Continuous Deployment
Vercel automatically deploys:- Production: Commits to your main/master branch
- Preview: Pull requests and other branches
Environment-Specific Builds
The project supports different build modes:Troubleshooting
Build Failures
If builds fail:- Check the build logs in Vercel dashboard
- Verify all dependencies are listed in
package.json - Ensure Node.js version compatibility (v20+)
- Check for TypeScript or ESLint errors
API Routes Not Working
- Verify
vercel.jsonconfiguration is correct - Check that API functions are in the correct directory
- Review function logs in Vercel dashboard
- Ensure environment variables are set correctly
Database Connection Issues
- Verify
DATABASE_URLis set correctly - Check database allows connections from Vercel IPs
- Ensure
pgvectorextension is enabled - Test connection using Prisma Studio
Next Steps
Environment Setup
Complete guide to environment variables
Railway Deployment
Alternative deployment option