Deploy to Vercel
Step-by-step guide to deploying Next Starter on Vercel, including all required environment variables, Stripe webhook configuration, custom domain setup, and preview deployment best practices.
Overview
Vercel is the recommended deployment target for Next Starter. It provides native Next.js support, automatic preview deployments per pull request, and a dashboard for managing environment variables and custom domains.
Import from GitHub
- Push your project to a GitHub repository (or GitLab / Bitbucket).
- Go to vercel.com/new and click Import.
- Select your repository.
- Vercel detects Next.js automatically. Leave the framework preset as Next.js and keep the build settings at their defaults.
- Add all required environment variables before clicking Deploy. The build script runs
prisma migrate deployas part ofpnpm build, soDATABASE_URLmust be present at build time, not just at runtime. - Click Deploy.
Environment Variables
Open your project in the Vercel dashboard, then go to Settings > Environment Variables.
Add each variable from your .env file. The minimum required for a working production deployment:
# Database
DATABASE_URL="postgresql://user:password@host:5432/dbname"
# Optional: if your provider uses a connection pooler (e.g. Neon, Supabase),
# store the direct (non-pooled) connection string here. Not consumed by default —
# prisma.config.ts only reads DATABASE_URL.
DIRECT_DATABASE_URL="postgresql://user:password@host:5432/dbname"
# Better Auth
BETTER_AUTH_SECRET="your-32-character-secret"
BETTER_AUTH_URL="https://yourdomain.com"
NEXT_PUBLIC_BETTER_AUTH_URL="https://yourdomain.com"
# App
PUBLIC_URL="https://yourdomain.com"
NEXT_PUBLIC_APP_NAME="Your App Name"
# Stripe
STRIPE_SECRET_KEY="sk_live_..."
STRIPE_WEBHOOK_SECRET="whsec_..."
STRIPE_PUBLISHABLE_KEY="pk_live_..."
# SMTP2Go
SMTP2GO_API_KEY="your-api-key"
SENDER_EMAIL="noreply@yourdomain.com"
# Cloudflare R2
STORAGE_S3_ENDPOINT="https://<account>.r2.cloudflarestorage.com"
STORAGE_S3_BUCKET="your-bucket"
STORAGE_S3_KEY="your-key-id"
STORAGE_S3_SECRET="your-secret"
STORAGE_S3_REGION="auto"
NEXT_PUBLIC_STORAGE_S3_CDN_URL="https://your-r2-cdn-domain.com"
# Google OAuth
GOOGLE_CLIENT_ID="your-google-client-id"
GOOGLE_CLIENT_SECRET="your-google-client-secret"
# reCAPTCHA (optional)
NEXT_PUBLIC_RECAPTCHA_SITE_KEY="your-site-key"
RECAPTCHA_SECRET_KEY="your-secret-key"Set variables for the Production, Preview, and Development environments as appropriate. You can use different Stripe test keys and a separate database for Preview environments.
After adding or changing variables, redeploy for the changes to take effect.
Triggering a Redeploy
Any push to your main branch triggers a new production deployment automatically. To redeploy without a code change, go to Deployments, find the latest deployment, and click Redeploy.
Custom Domain
- In the Vercel dashboard, go to Settings > Domains.
- Enter your domain name and click Add.
- Vercel displays the DNS records to add, typically a CNAME for
wwwor an A record for the apex domain. - Add those records in your DNS provider's dashboard.
- Vercel provisions an SSL certificate automatically via Let's Encrypt once DNS propagates.
After the domain is active, update BETTER_AUTH_URL, NEXT_PUBLIC_BETTER_AUTH_URL, and PUBLIC_URL to match your custom domain.
Preview Deployments
Every pull request gets its own preview URL at your-project-git-{branch}-{username}.vercel.app. Use this to review changes before merging to production.
To prevent preview deployments from sending real emails or charging real Stripe customers, set the Preview environment scope to use test credentials:
- Set
STRIPE_SECRET_KEYto ask_test_...key for Preview. - Point
DATABASE_URLat a separate staging database for Preview. - Use a non-production SMTP2Go sender address.
Recommended Settings
Build & Development Settings
| Setting | Value |
|---|---|
| Framework Preset | Next.js |
| Build Command | pnpm build |
| Output Directory | .next (default) |
| Install Command | pnpm install --frozen-lockfile |
The pnpm build script expands to prisma generate && prisma migrate deploy && next build. Prisma migrations run on every deploy, so DATABASE_URL must be set as a build-time environment variable in Vercel.
Performance
- Enable Edge Network caching. Vercel handles this automatically for static assets.
- Next Starter uses
output: "standalone"innext.config.ts. Vercel does not use the standalone output directly; it runs its own optimized build pipeline. This setting exists for Docker deployments and does not interfere with Vercel.
Functions
Next Starter's API routes run as Vercel Serverless Functions by default. If you need longer execution times (for example, large file processing), configure maxDuration in individual route files:
export const maxDuration = 60; // secondsStripe Webhooks on Vercel
After deploying, register your production webhook endpoint with Stripe:
- Go to the Stripe Dashboard > Webhooks.
- Click Add endpoint.
- Set the endpoint URL to
https://yourdomain.com/api/auth/stripe/webhook. - Select the events your app handles. At minimum:
customer.subscription.*andinvoice.*. - Copy the Signing secret and set it as
STRIPE_WEBHOOK_SECRETin Vercel.
Redeploy after updating the webhook secret.
Database Setup
How to configure PostgreSQL with Prisma 7 for Next Starter, including local Docker setup, running migrations, hosted database providers, and connection pooling for serverless deployments.
Docker Deployment
Self-host Next Starter with Docker using the included Dockerfile, docker-compose, and Next.js standalone output mode. Covers building, environment variables, and running database migrations.