OpenSky-commerce / Documentation

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)

  1. In your Vercel dashboard, go to Storage → Create Database.
  2. Select Postgres (Neon) and follow the setup wizard.
  3. Vercel will automatically inject the DATABASE_URL environment variable into your project — no manual copy needed.

Option B: External Database (Neon, Supabase, Railway, etc.)

  1. Create a PostgreSQL database on your chosen provider.
  2. Copy the connection string (with SSL mode included if required).
  3. You will add it as an environment variable in Step 3.

Step 2 — Import Your Project

  1. Go to vercel.com/new.
  2. Click Import Git Repository and select your private repo.
  3. Vercel auto-detects Next.js. Confirm the framework is set to Next.js.
  4. 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.com

Add 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 deploy

Alternatively, 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 deploy

Step 6 — Add a Custom Domain

  1. In your Vercel project, go to Settings → Domains.
  2. Click Add and enter your domain.
  3. Follow the DNS instructions (add a CNAME or A record at your domain registrar).
  4. Vercel provisions an SSL certificate automatically. Your site will be live on HTTPS within minutes of DNS propagation.
  5. Update NEXTAUTH_URL and NEXT_PUBLIC_SITE_URL to your custom domain in project environment variables. The next deployment will pick up the change.

Step 7 — Stripe Webhook (if using Stripe)

  1. In the Stripe dashboard, go to Developers → Webhooks → Add endpoint.
  2. Enter: https://yourdomain.com/api/webhooks/stripe
  3. Subscribe to payment_intent.succeeded and payment_intent.payment_failed.
  4. Copy the signing secret and add it as STRIPE_WEBHOOK_SECRET in 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=production automatically. Make sure Prisma is in dependencies (not only devDependencies).

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.