Vercel Deployment

Deploy your Kit application to Vercel with preview environments, cron jobs, and custom domains

Vercel is the recommended hosting platform for Kit. It provides zero-configuration Next.js deployment, automatic preview environments for every pull request, built-in analytics, and edge network distribution — all optimized for the Next.js App Router that Kit uses.

Prerequisites

Before deploying, make sure you have:
  • A Vercel account (free tier works for getting started)
  • Your Kit repository pushed to GitHub
  • All external services configured (database, Clerk, Lemon Squeezy, etc.)

Create a Vercel Project

1

Connect your repository

  1. Go to vercel.com/new
  2. Select Import Git Repository and choose your Kit repository
  3. Vercel auto-detects the Next.js framework
2

Configure build settings

Set the following build configuration:
SettingValue
Framework PresetNext.js
Build Commandpnpm build
Output Directory.next (default)
Install Commandpnpm install
Node.js Version20.x
3

Deploy

Click Deploy. Vercel runs the build command, bundles your application, and deploys it to a .vercel.app subdomain. The first deployment typically takes 2-3 minutes.

Environment Variables

Configure all required environment variables in the Vercel Dashboard under Settings > Environment Variables. Group them by service:

Core Services

VariableServiceRequired
DATABASE_URLSupabase (pooled connection)Yes
DIRECT_URLSupabase (direct connection)Yes
NEXT_PUBLIC_SUPABASE_URLSupabaseYes
NEXT_PUBLIC_SUPABASE_ANON_KEYSupabaseYes
SUPABASE_SERVICE_ROLE_KEYSupabaseYes
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEYClerkYes
CLERK_SECRET_KEYClerkYes
CLERK_WEBHOOK_SECRETClerkYes
LEMONSQUEEZY_API_KEYLemon SqueezyYes
LEMONSQUEEZY_STORE_IDLemon SqueezyYes
LEMONSQUEEZY_WEBHOOK_SECRETLemon SqueezyYes
RESEND_API_KEYResendYes
RESEND_FROM_EMAILResendYes
BLOB_READ_WRITE_TOKENVercel BlobYes
UPSTASH_REDIS_REST_URLUpstash RedisYes
UPSTASH_REDIS_REST_TOKENUpstash RedisYes

Application Settings

VariablePurposeExample
NEXT_PUBLIC_APP_URLProduction domainhttps://yourdomain.com
ALLOWED_ORIGINSCORS whitelisthttps://yourdomain.com
CRON_SECRETVercel cron authenticationRandom 32+ char string
COLOR_THEMEUI color themedefault
NEXT_PUBLIC_PRICING_MODELPricing modecredit_based or subscription

AI Provider Keys (Optional)

VariableProvider
OPENAI_API_KEYOpenAI
ANTHROPIC_API_KEYAnthropic
GOOGLE_GENERATIVE_AI_API_KEYGoogle AI
XAI_API_KEYxAI
Enable AI features with feature flags:
FlagFeature
NEXT_PUBLIC_AI_LLM_CHAT_ENABLEDLLM Chat interface
NEXT_PUBLIC_AI_RAG_CHAT_ENABLEDRAG Chat with document upload

Production Configuration

Kit includes two configuration files that Vercel reads automatically during deployment.

Cron Jobs

The vercel.json file defines scheduled tasks that run automatically:
vercel.json — Cron Job Configuration
{
  "crons": [
    {
      "path": "/api/cron/check-trials",
      "schedule": "0 2 * * *"
    },
    {
      "path": "/api/cron/expire-bonus-credits",
      "schedule": "0 3 * * *"
    }
  ]
}
Cron JobSchedulePurpose
/api/cron/check-trialsDaily at 2:00 AM UTCDetects expired trial subscriptions and downgrades users
/api/cron/expire-bonus-creditsDaily at 3:00 AM UTCRemoves expired bonus credits from user accounts
Both endpoints verify the CRON_SECRET environment variable before executing. Set this to a random string of at least 32 characters in your Vercel environment variables.

Next.js Configuration

The next.config.mjs includes production-critical settings that apply automatically:
next.config.mjs — Core Production Settings
const nextConfig = {
  pageExtensions: ['js', 'jsx', 'ts', 'tsx'],
  reactStrictMode: true,
  swcMinify: true,
  • reactStrictMode — Catches common bugs during development, zero overhead in production
  • swcMinify — Uses the SWC compiler for minification (faster than Terser)
  • image formats — Serves AVIF and WebP automatically based on browser support
next.config.mjs — Security Headers
// Security Headers
  async headers() {
    return [
      {
        source: '/:path*',
        headers: [
          {
            key: 'X-DNS-Prefetch-Control',
            value: 'on',
          },
          {
            key: 'X-Frame-Options',
            value: 'SAMEORIGIN',
          },
          {
            key: 'X-Content-Type-Options',
            value: 'nosniff',
          },
          {
            key: 'X-XSS-Protection',
            value: '1; mode=block',
          },
          {
            key: 'Referrer-Policy',
            value: 'strict-origin-when-cross-origin',
          },
          {
            key: 'Permissions-Policy',
            value: 'camera=(), microphone=(self), geolocation=(), interest-cohort=(), payment=(), usb=()',
          },
          {
            key: 'Content-Security-Policy',
            value: ContentSecurityPolicy.replace(/\s{2,}/g, ' ').trim(),
          },
        ],
      },
    ]
  },
These security headers are applied to all routes and include Content-Security-Policy, X-Frame-Options, X-Content-Type-Options, and Referrer-Policy. See the Security Overview for details on each header.

Preview Deployments

Every pull request automatically receives its own deployment URL. Vercel creates a unique preview environment with the PR's code, adds a comment to the PR with the preview link, and tears it down when the PR is closed.
Preview deployments are useful for:
  • Code review — Reviewers can test changes in a real environment before merging
  • QA testing — Test payment flows, auth flows, and AI features without affecting production
  • Stakeholder demos — Share a link with non-technical team members

Custom Domain

1

Add your domain

Go to Settings > Domains in your Vercel project and add your domain (e.g., yourdomain.com).
2

Configure DNS

Add the DNS records Vercel provides. Typically:
TypeNameValue
A@76.76.21.21
CNAMEwwwcname.vercel-dns.com
3

Update environment variables

Set NEXT_PUBLIC_APP_URL to your production domain:
bash
NEXT_PUBLIC_APP_URL=https://yourdomain.com
Also update ALLOWED_ORIGINS to include your domain for CORS:
bash
ALLOWED_ORIGINS=https://yourdomain.com
4

Update external services

Point webhooks and callback URLs to your production domain:
  • Clerk — Update the sign-in/sign-up redirect URLs and webhook endpoint
  • Lemon Squeezy — Update the webhook URL to https://yourdomain.com/api/webhooks/lemonsqueezy
  • Resend — Verify your domain for email sending

Manual Deployment via CLI

For cases where you need to deploy outside of the GitHub integration (debugging, hotfixes), use the Vercel CLI:
bash
# Install Vercel CLI
pnpm add -g vercel@latest

# Login to Vercel
vercel login

# Deploy to preview
vercel

# Deploy to production
vercel --prod
The CI/CD pipeline uses --archive=tgz to compress files before upload, which avoids rate limits on projects with many files:
bash
vercel deploy --prebuilt --prod --archive=tgz --token=$VERCEL_TOKEN

Troubleshooting

Build fails with missing environment variables

Vercel builds run in a clean environment. Every variable your build process reads must be configured in the Vercel Dashboard. Check the build logs for undefined values and add the missing variables.

Cron jobs not running

  1. Verify vercel.json is in the project root (or the Root Directory you configured)
  2. Confirm CRON_SECRET is set in Production environment variables
  3. Check the Cron tab in Vercel Dashboard to see execution history

Preview deployments not appearing

Ensure the Vercel GitHub integration has access to the repository. Go to Settings > Git in Vercel and verify the connected repository.