Deployment Guide
This guide covers deploying the Next.js application to Vercel with Convex backend integration.
Prerequisites
-
A GitHub account with the repository cloned
-
A Vercel account (sign up at vercel.com)
-
A Convex account (sign up at convex.dev)
-
Node.js 24+ installed locally
-
pnpm 11.17.0 via Corepack (root
packageManagerpin)
Git Remote Configuration
Before deploying, ensure your git remotes are configured correctly:
Check Current Remotes
git remote -v
You should see:
* origin pointing to your fork (e.g., https://github.com/YourUsername/ftn-site.git)
* upstream pointing to the original repository (e.g., https://github.com/FoodTruckNerdz/ftn-site.git)
Vercel Project Setup
1. Create a New Vercel Project
-
Go to Vercel Dashboard
-
Click "Add New…" → "Project"
-
Import your GitHub repository
-
Select the repository from the list
2. Configure Project Settings
In the project configuration screen, set the following:
Root Directory
Set the Root Directory to site-nextjs:
-
In Vercel project settings, go to "Settings" → "General"
-
Under "Root Directory", enter:
site-nextjs -
This tells Vercel to treat the
site-nextjsfolder as the project root
Build & Output Settings
The project includes a vercel.json file in the site-nextjs directory that configures:
-
Build Command:
pnpm build:vercel(production: Convex deploy + Next.js; Preview: Next.js only against shared prod Convex) -
Framework:
nextjs
If you need to override these in the Vercel dashboard:
-
Build Command:
pnpm build:vercel -
Output Directory: Leave empty (Vercel auto-detects
.nextfor Next.js) -
Install Command:
pnpm install --frozen-lockfileIf Vercel can’t see the monorepo lockfile from
site-nextjs/, use:cd .. && pnpm install --frozen-lockfile(run the install from the workspace root).
Node.js Version
-
In "Settings" → "General" → "Node.js Version"
-
Set to
24.x(matches yourpackage.jsonengines requirement)
Reproducible Vercel settings (copy/paste)
Set these values so a fresh Vercel project reproduces the same monorepo build behavior:
-
Root Directory:
site-nextjs -
Build Command:
pnpm build:vercel -
Install Command:
pnpm install --frozen-lockfile -
If Vercel can’t see the workspace lockfile from
site-nextjs/, use:cd .. && pnpm install --frozen-lockfile -
Framework:
nextjs -
Output Directory: leave empty
-
Node.js Version:
24.x -
Include source files outside of the Root Directory: enable (so Vercel can read root
pnpm-workspace.yaml/pnpm-lock.yaml)
Convex Deployment Setup
1. Create a Production Deployment
From your local machine, create a production Convex deployment:
cd site-nextjs
pnpm convex deploy
This will: * Create a production deployment in your Convex account * Deploy your Convex functions and schema * Provide a deployment URL
The --prod flag is not needed when using pnpm convex deploy --cmd in Vercel, as Convex automatically uses the production deployment in CI/CD environments.
|
2. Generate a Convex Deploy Key
-
Go to your Convex Dashboard
-
Navigate to your project settings
-
Go to "Deploy Keys" or "Settings" → "Deploy Keys"
-
Click "Generate Deploy Key"
-
Copy the generated key (you’ll need this for Vercel)
3. Configure Convex in Vercel
-
In Vercel, go to your project → "Settings" → "Environment Variables"
-
Add the following environment variable:
-
Name:
CONVEX_DEPLOY_KEY -
Value: Paste the deploy key you generated from Convex
-
Environment: Production only (not Preview or Development while sharing prod data)
-
Name:
NEXT_PUBLIC_CONVEX_URL -
Value: The production
https://<deployment>.convex.cloudURL -
Environment: Preview and Development (and Production as a fallback)
-
CONVEX_DEPLOY_KEY on Preview would let branch builds push functions onto production Convex. Until release, Preview only reads/writes data via NEXT_PUBLIC_CONVEX_URL.
|
4. How Convex Deployment Works
When Vercel builds production:
-
pnpm build:vercelseesVERCEL_ENV=productionand runspnpm convex deploy --cmd 'pnpm build' -
Convex deploys functions from
convex/usingCONVEX_DEPLOY_KEY -
Next.js builds against that deployment
When Vercel builds Preview (or Development):
-
pnpm build:vercelrunspnpm buildonly -
The app uses dashboard
NEXT_PUBLIC_CONVEX_URL(same production data plane) -
Functions already on that Convex deployment are used; the Preview git branch does not
convex deploy
Environment Variables
Required Environment Variables
Add these in Vercel → "Settings" → "Environment Variables":
-
CONVEX_DEPLOY_KEY— Production only -
NEXT_PUBLIC_CONVEX_URL— Preview + Development (shared prod Convex until release)
Optional Environment Variables
If you have other API keys or configuration, add them here:
-
Square API keys (if using Square integration)
-
Radar SDK keys (if using location services)
-
Any other service API keys your app requires
Set each variable for the appropriate environments: * Production: Used for production deployments * Preview: Used for preview deployments (pull requests, branches) * Development: Used for local development (if using Vercel CLI)
Deploying
Manual Deployment via CLI
If you need to force a deployment from your local machine (e.g., after changing the folder structure), you can use the Vercel CLI.
In a pnpm workspace, the directory context matters. Vercel needs the root pnpm-lock.yaml and pnpm-workspace.yaml. Local installs always run pnpm install from the repository root. See Tooling.
|
2. Link your project
Run this from the repository root (where pnpm-workspace.yaml is):
vercel link
Select your existing project from the list. This creates a .vercel folder at the root.
3. Force a Production Deployment
Run this also from the repository root:
vercel --prod
|
When running Select NO (Reject this option). Pulling environment variables from Vercel can overwrite your local configuration or create |
Vercel will use the Root Directory setting you configured in the dashboard (e.g., site-nextjs) to find the actual code, but running it from the repo root ensures all workspace dependencies are correctly uploaded.
Common Pitfalls
-
Broken Paths: If you run
vercel --prodfrom inside thesite-nextjsfolder, the CLI might try to look forsite-nextjs/site-nextjsbecause it applies the dashboard’s "Root Directory" setting relative to your current path. Always run from the repo root or use the--cwd .flag to override. -
Node Version Mismatch: If you get a local warning about Node versions, ensure both your machine and Vercel are set to Node 24.
Troubleshooting
Build Fails with "CONVEX_DEPLOY_KEY not found"
-
Ensure
CONVEX_DEPLOY_KEYis set in Vercel environment variables -
Verify it’s available for the environment you’re deploying to (Production/Preview)
-
Regenerate the key in Convex dashboard if needed
Build Fails with "NEXT_PUBLIC_CONVEX_URL is not set"
-
This usually means Convex deployment failed
-
Check that
CONVEX_DEPLOY_KEYis correct -
Verify your Convex project is properly configured
-
Check build logs for Convex-specific errors
Best Practices
Shared data until release
Until apex launch, local next dev and Vercel Preview share production Convex data. Do not run npx convex dev against that URL. After release, split a staging/dev Convex and point Preview + local at it.
Environment-Specific Configuration
-
Use different Convex deployments for Production vs Preview if needed
-
Set environment-specific variables in Vercel
-
Test preview deployments before merging to main
Monitoring
-
Monitor Convex dashboard for function usage and errors
-
Check Vercel analytics for frontend performance
-
Dedicated website performance monitoring and website testing are on the product roadmap — no vendor research yet (see Monitoring & testing (roadmap)). A casual “e.g., Sentry” example is not a stack choice.
Next Steps
After successful deployment:
-
Test your production URL
-
Verify Convex functions are working
-
Check that all API integrations are functioning
-
Monitor for any errors or issues
For local development setup, see Getting Started.
For Convex-specific setup details, see Convex setup.