This guide will help you deploy your Next.js application to Vercel with a cloud-hosted database.
For detailed step-by-step instructions, see:
- Vercel Deployment Guide - Complete guide for deploying to Vercel
- Supabase Integration Guide - Guide for setting up Supabase
- Supabase Data Management - Guide for managing data in Supabase
- A Vercel account
- A cloud database service account (Supabase, PlanetScale, etc.)
- Create an account at Supabase
- Create a new database project
- Get your Supabase URL and anon key from the project settings
- Either:
- Run the SQL migration script in
/scripts/supabase-migration.sqlusing the Supabase SQL editor - Configure your environment variables and run
npm run setup-supabase
- Run the SQL migration script in
For detailed instructions, see Supabase Integration Guide
- Create an account at PlanetScale
- Create a new database
- Get your database connection string from the "Connect" tab
- Create the required tables by running the scripts in
/scripts/init-db.js
- Create a MySQL database instance
- Note your connection details (host, username, password, database name)
- Make sure to configure the database to accept connections from Vercel's IP ranges
- Run the initialization script from your local machine or a VM with access to the database
- Push your code to a Git repository (GitHub, GitLab, or Bitbucket)
- Connect your repository to Vercel
- In the Vercel project settings, add the following environment variables:
# For Supabase (PostgreSQL)
NEXT_PUBLIC_SUPABASE_URL=your-supabase-url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-supabase-anon-key
# For MySQL (if using)
DB_HOST=your-database-host
DB_USER=your-database-user
DB_PASSWORD=your-database-password
DB_NAME=your-database-name
# Environment and Authentication
NODE_ENV=production
JWT_SECRET=your-secure-random-string- Deploy your application
- Check that your application is functioning correctly
- Verify database connections are working
- Test all your application's features
- If you encounter database connection issues, ensure your database allows connections from Vercel's IP addresses
- Check the Vercel deployment logs for detailed error messages
- Verify your environment variables are correctly set in the Vercel dashboard
For local development, use the .env.local file with your local database credentials.