Deploy to Vercel
Vercel is the company that builds Next.js, and their platform has first-class support for it. It is the fastest way to get Open Sky Commerce online — deployments happen in about two minutes from a git push, with zero server configuration.
Prerequisites
- A Vercel account — vercel.com (free tier is sufficient to start)
- Your code in a private GitHub, GitLab, or Bitbucket repository
- A PostgreSQL database. Vercel offers Vercel Postgres (powered by Neon) directly in their dashboard, or you can use any external provider — Neon, Supabase, Railway, or DigitalOcean Managed Databases all work.
Step 1 — Set Up a PostgreSQL Database
Option A: Vercel Postgres (Neon)
- In your Vercel dashboard, go to Storage → Create Database.
- Select Postgres (Neon) and follow the setup wizard.
- Vercel will automatically inject the
DATABASE_URLenvironment variable into your project — no manual copy needed.
Option B: External Database (Neon, Supabase, Railway, etc.)
- Create a PostgreSQL database on your chosen provider.
- Copy the connection string (with SSL mode included if required).
- You will add it as an environment variable in Step 3.
Step 2 — Import Your Project
- Go to vercel.com/new.
- Click Import Git Repository and select your private repo.
- Vercel auto-detects Next.js. Confirm the framework is set to Next.js.
- Do not click Deploy yet — configure environment variables first.
Step 3 — Add Environment Variables
On the project import screen, expand Environment Variables and add the following. You can also add them later under Project Settings → Environment Variables.
# Required
DATABASE_URL=postgresql://... # from Step 1
NEXTAUTH_URL=https://yourdomain.com # your final production URL
NEXTAUTH_SECRET= # openssl rand -base64 32
NEXT_PUBLIC_SITE_URL=https://yourdomain.comAdd all other optional variables for services you have enabled. See Environment Variables for the complete list.
Tip: Set the environment scope to Production for live keys and Preview for test/sandbox keys. That way test credentials are used automatically on preview deployments.
Step 4 — Deploy
Click Deploy. Vercel will clone your repo, run npm run build, and deploy the result. The first build takes about 60–120 seconds.
You will get a temporary URL like yourproject.vercel.app immediately. Every future push to your production branch triggers an automatic redeployment.
Step 5 — Run Database Migrations
Run Prisma migrations against your production database from your local machine:
# Replace the URL with your production database connection string
DATABASE_URL="postgresql://..." npx prisma migrate deployAlternatively, use the Vercel CLI to run a one-off command in the production environment:
# Install Vercel CLI
npm i -g vercel
# Run in production environment
vercel env pull .env.production.local
DATABASE_URL=$(grep DATABASE_URL .env.production.local | cut -d= -f2-) npx prisma migrate deployStep 6 — Add a Custom Domain
- In your Vercel project, go to Settings → Domains.
- Click Add and enter your domain.
- Follow the DNS instructions (add a CNAME or A record at your domain registrar).
- Vercel provisions an SSL certificate automatically. Your site will be live on HTTPS within minutes of DNS propagation.
- Update
NEXTAUTH_URLandNEXT_PUBLIC_SITE_URLto your custom domain in project environment variables. The next deployment will pick up the change.
Step 7 — Stripe Webhook (if using Stripe)
- In the Stripe dashboard, go to Developers → Webhooks → Add endpoint.
- Enter:
https://yourdomain.com/api/webhooks/stripe - Subscribe to
payment_intent.succeededandpayment_intent.payment_failed. - Copy the signing secret and add it as
STRIPE_WEBHOOK_SECRETin your Vercel environment variables.
Automatic Deployments
Vercel deploys automatically on every push to the main branch. Pull requests get their own preview deployment URLs — a great way to test changes before merging.
Vercel Limitations to Know
- Serverless function timeout: Vercel serverless functions time out after 10 seconds on the free tier (60 seconds on Pro). The data import script (
import-demo-data) is a local script and is not affected. But if you build any long-running API routes, be aware of this limit. - No persistent filesystem: Vercel deployments are stateless. All file uploads must go to DigitalOcean Spaces or another external storage service — never to the local filesystem.
- Build environment: Vercel sets
NODE_ENV=productionautomatically. Make sure Prisma is independencies(not onlydevDependencies).
Troubleshooting
Build fails: "Cannot find module @prisma/client"
Move prisma and @prisma/client from devDependencies to dependencies in package.json.
NEXTAUTH_URL warnings in logs
This usually means NEXTAUTH_URL is not set or does not match the deployment URL. Ensure it is set to your exact production URL with https:// and no trailing slash.
Database connection errors in production
Serverless environments like Vercel open many short-lived database connections. If you see "too many connections" errors, add ?pgbouncer=true&connection_limit=1 to your DATABASE_URL, or use a connection pooler like Neon's built-in pooler.