Prerequisites
Before deploying to Vercel, ensure you have:- A Vercel account (sign up at vercel.com)
- Your GitHub, GitLab, or Bitbucket repository connected
- PostgreSQL database ready (e.g., Supabase)
- All required environment variables prepared
Quick deployment
Import your repository
- Log in to your Vercel dashboard
- Click “Add New” > “Project”
- Import your Git repository
- Select the repository containing Biovity
Configure project settings
Vercel automatically detects Next.js projects. Verify these settings:
- Framework Preset: Next.js
- Root Directory:
./(or your source directory) - Build Command:
bun buildornext build --turbopack - Output Directory:
.next(automatic) - Install Command:
bun installornpm install
Add environment variables
Add all required environment variables in the Vercel dashboard:
- Go to “Environment Variables” section
- Add each variable from your
.env.example:DATABASE_URLBETTER_AUTH_SECRETBETTER_AUTH_URLNEXT_PUBLIC_APP_URLNEXT_PUBLIC_SITE_URL
- Select environments: Production, Preview, Development
Your first deployment may take 2-5 minutes. Subsequent deployments are typically faster due to caching.
Vercel configuration
Biovity includes avercel.json configuration file for advanced settings.
Cron jobs
The project includes a cron job configuration:- Path:
/api/cron- The API endpoint to call - Schedule:
0 10 */5 * *- Runs at 10:00 AM every 5 days - Format: Standard cron expression format
Domain configuration
Add custom domain
In your Vercel project settings:
- Go to “Settings” > “Domains”
- Add your custom domain (e.g.,
yourdomain.com) - Follow the DNS configuration instructions
Automatic deployments
Vercel automatically deploys your application when you push to Git:- Production deployments: Triggered by pushes to your main/master branch
- Preview deployments: Created for every pull request
- Branch deployments: Each branch gets its own preview URL
Preview deployments
Preview deployments are perfect for testing changes before merging:- Each PR gets a unique URL
- Environment variables can be configured separately for previews
- Automatic comments on PRs with deployment status
Environment-specific variables
You can set different values for each environment:- Production: Used for your production domain
- Preview: Used for PR previews and branch deployments
- Development: Used when developing locally with Vercel CLI
Performance monitoring
Vercel provides built-in monitoring tools:Analytics
Biovity includes@vercel/analytics for tracking:
- Page views
- User interactions
- Web vitals
Speed Insights
Biovity includes@vercel/speed-insights for performance monitoring:
- Core Web Vitals
- Real user metrics
- Performance scores
Build settings
Recommended settings
Node.js version
Vercel automatically uses the latest LTS Node.js version. To specify a version, add topackage.json:
Troubleshooting
Build fails
- Check build logs in Vercel dashboard
- Verify all environment variables are set
- Ensure dependencies are installed correctly
- Run
bun typecheckandbun checklocally
Authentication issues
If Better Auth doesn’t work after deployment:- Verify
BETTER_AUTH_URLmatches your production URL - Check that
BETTER_AUTH_SECRETis set in Vercel environment variables - Ensure the auth API route is accessible at
/api/auth/[...all]
Database connection errors
- Verify
DATABASE_URLis correct - Check that your database allows connections from Vercel’s IP ranges
- For Supabase, ensure you’re using the connection pooler URL
Cron job not running
- Verify you’re on a Pro or Enterprise plan
- Check the cron schedule syntax in
vercel.json - View cron job logs in Vercel dashboard under “Cron Jobs”
Security best practices
- Generate unique secrets for production using
openssl rand -base64 32 - Use different database credentials for production and preview
- Enable Vercel’s “Automatically expose System Environment Variables” only if needed
- Regularly rotate authentication secrets
- Use Vercel’s IP allowlisting for sensitive API routes