Overview
This guide walks you through deploying the Next.js application to Vercel, the recommended hosting platform for Next.js applications.Prerequisites
- GitHub account with your repository
- Vercel account (sign up at vercel.com)
- Environment variables configured (see Environment Variables)
Deployment Steps
Connect Your Repository
- Log in to your Vercel account
- Click “Add New Project”
- Import your GitHub repository
- Select the repository containing your Next.js application
Configure Build Settings
Vercel automatically detects Next.js projects. Verify the following settings:
- Framework Preset: Next.js
- Build Command:
next build - Output Directory:
.next(auto-detected) - Install Command:
npm install(or your package manager)
The build command
next build is defined in package.json under the build script.Set Environment Variables
Configure the required environment variables in Vercel:
- Navigate to “Environment Variables” section
- Add the following variables (see Environment Variables for details):
NEXT_PUBLIC_SUPABASE_URLNEXT_PUBLIC_SUPABASE_ANON_KEYCRON_SECRET
Vercel Configuration
The project includes avercel.json configuration file that sets up scheduled cron jobs:
vercel.json
/api/cron endpoint. The cron job verifies Supabase connectivity by checking the messages table.
Cron jobs on Vercel require a Pro plan or higher. The cron endpoint is protected by the
CRON_SECRET environment variable.Next.js Configuration
Thenext.config.ts file includes image optimization settings:
next.config.ts
Post-Deployment
After successful deployment:- Visit your deployed site URL
- Test the Supabase integration
- Verify environment variables are working correctly
- Check the cron job logs in Vercel dashboard (if using Pro plan)
Troubleshooting
Build Fails
- Check build logs for specific errors
- Verify all environment variables are set correctly
- Ensure dependencies in
package.jsonare up to date
Runtime Errors
- Check function logs in Vercel dashboard
- Verify Supabase credentials are correct
- Ensure database tables exist and are accessible
Cron Job Not Running
- Verify you have a Vercel Pro plan or higher
- Check the
CRON_SECRETenvironment variable is set - Review cron job logs in Vercel dashboard
Automatic Deployments
Vercel automatically deploys your application when you push to your connected Git repository:- Production: Deployments from your main/master branch
- Preview: Deployments from pull requests and other branches