Skip to main content

Overview

Dub requires various environment variables for configuration. This page provides a comprehensive reference for all available options.
All environment variables should be set in the .env file in the apps/web directory.

Required Variables

These variables are essential for Dub to function properly.

Application Configuration

NEXT_PUBLIC_APP_NAME
string
required
The name of your application.Default: Dub
NEXT_PUBLIC_APP_NAME=Dub
NEXT_PUBLIC_APP_DOMAIN
string
required
The primary domain where your Dub instance is hosted.Example: dub.co
NEXT_PUBLIC_APP_DOMAIN=yourdomain.com
NEXT_PUBLIC_APP_SHORT_DOMAIN
string
required
The domain used for shortened links.Example: dub.sh
NEXT_PUBLIC_APP_SHORT_DOMAIN=yourdomain.link

Analytics & Tracking

TINYBIRD_API_KEY
string
required
Your Tinybird API authentication token. Required for analytics functionality.Get your token at: Tinybird Auth Tokens
TINYBIRD_API_KEY=p.ey...
TINYBIRD_API_URL
string
required
The Tinybird API endpoint for your region.Default: https://api.tinybird.coRegions:
  • US East: https://api.tinybird.co
  • EU: https://api.eu-central-1.tinybird.co
  • US West: https://api.us-west-2.tinybird.co
View all regions
TINYBIRD_API_URL=https://api.tinybird.co

Domain Management

PROJECT_ID_VERCEL
string
required
Your Vercel project ID for domain management.Learn more: Vercel Domains API Template
PROJECT_ID_VERCEL=prj_...
TEAM_ID_VERCEL
string
required
Your Vercel team ID.
TEAM_ID_VERCEL=team_...
AUTH_BEARER_TOKEN
string
required
Vercel authentication bearer token for API access.
AUTH_BEARER_TOKEN=...

Redis & Caching

UPSTASH_REDIS_REST_URL
string
required
Upstash Redis REST API URL.Get started: Upstash Redis Guide
UPSTASH_REDIS_REST_URL=https://....upstash.io
UPSTASH_REDIS_REST_TOKEN
string
required
Upstash Redis REST API token.
UPSTASH_REDIS_REST_TOKEN=...

Background Jobs & Queues

QSTASH_TOKEN
string
required
Upstash QStash token for background job processing.Get started: Upstash QStash Guide
QSTASH_TOKEN=...
QSTASH_CURRENT_SIGNING_KEY
string
required
Current QStash signing key for webhook verification.
QSTASH_CURRENT_SIGNING_KEY=...
QSTASH_NEXT_SIGNING_KEY
string
required
Next QStash signing key for key rotation.
QSTASH_NEXT_SIGNING_KEY=...

Database

DATABASE_URL
string
required
MySQL database connection URL.Format: mysql://username:password@host:port/databaseGet started with PlanetScale: Connect Node.js App
DATABASE_URL="mysql://user:password@host:3306/dub"
PLANETSCALE_DATABASE_URL
string
PlanetScale HTTP proxy URL for local development.Local development:
PLANETSCALE_DATABASE_URL="http://root:unused@localhost:3900/planetscale"

Authentication

NEXTAUTH_SECRET
string
required
Secret key for NextAuth.js session encryption. Must be a random 32+ character string.Generate one at: generate-secret.vercel.app/32
NEXTAUTH_SECRET=your-super-secret-key-here-32-chars-minimum
NEXTAUTH_URL
string
The canonical URL of your site. Required for localhost development.Production: Auto-detected by VercelLocal development:
NEXTAUTH_URL=http://localhost:8888

Email Configuration

RESEND_API_KEY
string
required
Resend API key for sending emails (production).Get your API key: Resend API Keys
RESEND_API_KEY=re_...
RESEND_WEBHOOK_SECRET
string
Resend webhook secret for email event verification.
RESEND_WEBHOOK_SECRET=whsec_...
SMTP_HOST
string
SMTP server hostname (recommended for local development).Local development with MailHog:
SMTP_HOST=localhost
SMTP_PORT
number
SMTP server port.Default: 1025 (MailHog)
SMTP_PORT=1025
SMTP_USER
string
SMTP authentication username.
SMTP_USER=smtpUser
SMTP_PASSWORD
string
SMTP authentication password.
SMTP_PASSWORD=smtpPassword
UNSUBSCRIBE_TOKEN_SECRET
string
Secret for email unsubscribe token generation. Falls back to NEXTAUTH_SECRET if not set.
UNSUBSCRIBE_TOKEN_SECRET=...

Optional Variables

These variables enable additional features and integrations.

Payments & Subscriptions

NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY
string
Stripe publishable key for client-side payment forms.
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_...
STRIPE_SECRET_KEY
string
Stripe secret key for server-side operations.
STRIPE_SECRET_KEY=sk_...
STRIPE_WEBHOOK_SECRET
string
Stripe webhook secret for payment event verification.
STRIPE_WEBHOOK_SECRET=whsec_...
STRIPE_CONNECT_WEBHOOK_SECRET
string
Stripe Connect webhook secret.
STRIPE_CONNECT_WEBHOOK_SECRET=whsec_...
STRIPE_CONNECT_V2_WEBHOOK_SECRET
string
Stripe Connect v2 webhook secret.
STRIPE_CONNECT_V2_WEBHOOK_SECRET=whsec_...
STRIPE_APP_WEBHOOK_SECRET
string
Stripe App webhook secret.
STRIPE_APP_WEBHOOK_SECRET=whsec_...

OAuth Providers

GOOGLE_CLIENT_ID
string
Google OAuth client ID for Google login.Setup guide: NextAuth.js Google Provider
GOOGLE_CLIENT_ID=...
GOOGLE_CLIENT_SECRET
string
Google OAuth client secret.
GOOGLE_CLIENT_SECRET=...
GITHUB_CLIENT_ID
string
GitHub OAuth app client ID for GitHub login.Setup guide: NextAuth.js GitHub Provider
GITHUB_CLIENT_ID=...
GITHUB_CLIENT_SECRET
string
GitHub OAuth app client secret.
GITHUB_CLIENT_SECRET=...
FRAMER_CLIENT_ID
string
Framer OAuth client ID for Framer login.
FRAMER_CLIENT_ID=...
FRAMER_CLIENT_SECRET
string
Framer OAuth client secret.
FRAMER_CLIENT_SECRET=...

Edge Configuration

EDGE_CONFIG
string
Vercel Edge Config connection string for admin features like rate limiting and user banning.Create one: Vercel Edge Config
EDGE_CONFIG=https://edge-config.vercel.com/...
If you don’t need admin features, you can remove lib/edge-config.ts and all references to EDGE_CONFIG from the codebase.
EDGE_CONFIG_ID
string
Vercel Edge Config ID.
EDGE_CONFIG_ID=ecfg_...
BITLY_CLIENT_ID
string
Bitly OAuth client ID for importing Bitly links.Apply for API access: Bitly DevelopersLearn more: Migration Assistants
BITLY_CLIENT_ID=...
BITLY_CLIENT_SECRET
string
Bitly OAuth client secret.
BITLY_CLIENT_SECRET=...

Media & Assets

UNSPLASH_ACCESS_KEY
string
Unsplash API key for custom link preview images.Apply for access: Unsplash Developers
UNSPLASH_ACCESS_KEY=...
STORAGE_ACCESS_KEY_ID
string
S3-compatible storage access key ID.
STORAGE_ACCESS_KEY_ID=...
STORAGE_SECRET_ACCESS_KEY
string
S3-compatible storage secret access key.
STORAGE_SECRET_ACCESS_KEY=...
STORAGE_ENDPOINT
string
S3-compatible storage endpoint URL.
STORAGE_ENDPOINT=https://s3.amazonaws.com
STORAGE_BASE_URL
string
Base URL for accessing stored assets.
STORAGE_BASE_URL=https://assets.yourdomain.com
STORAGE_PUBLIC_BUCKET
string
S3 bucket name for public assets.
STORAGE_PUBLIC_BUCKET=dub-public
STORAGE_PRIVATE_BUCKET
string
S3 bucket name for private assets.
STORAGE_PRIVATE_BUCKET=dub-private

Monitoring & Logging

AXIOM_TOKEN
string
Axiom API token for logging and monitoring.Get your token: Axiom Authentication
AXIOM_TOKEN=xaat-...
AXIOM_DATASET
string
Axiom dataset name for storing logs.
AXIOM_DATASET=dub-logs
DUB_SLACK_HOOK_CRON
string
Slack webhook URL for cron job notifications.
DUB_SLACK_HOOK_CRON=https://hooks.slack.com/services/...
You can remove these by deleting references to DUB_SLACK_HOOK_CRON and DUB_SLACK_HOOK_LINKS from the codebase.
Slack webhook URL for link-related notifications.
DUB_SLACK_HOOK_LINKS=https://hooks.slack.com/services/...

Customer Support

PLAIN_API_KEY
string
Plain API key for customer support integration.Get your API key: Plain API Documentation
PLAIN_API_KEY=plainApiKey_...
PLAIN_WEBHOOK_SECRET
string
Plain webhook secret for event verification.
PLAIN_WEBHOOK_SECRET=...

AI Features

ANTHROPIC_API_KEY
string
Anthropic API key for AI-powered features.
ANTHROPIC_API_KEY=sk-ant-...

Development Tools

NEXT_PUBLIC_NGROK_URL
string
ngrok URL for testing webhooks in local development.Get started: ngrok
NEXT_PUBLIC_NGROK_URL=https://....ngrok.io

Integrations

SHOPIFY_WEBHOOK_SECRET
string
Shopify App webhook secret.
SHOPIFY_WEBHOOK_SECRET=...

Internal Use Variables

These variables are used internally by Dub.co and are not required for self-hosted installations.
The following variables are for official Dub.co infrastructure only. You do not need to set these for self-hosted instances.
  • NEXT_PUBLIC_IS_DUB - Enables Dub.co specific features
  • CRON_SECRET - Secret for authenticating cron jobs
  • SLACK_CLIENT_ID / SLACK_CLIENT_SECRET / SLACK_SIGNING_SECRET - Slack integration
  • DYNADOT_API_KEY / DYNADOT_BASE_URL / DYNADOT_COUPON - Domain registration
  • TWITTER_CLIENT_ID / TWITTER_CLIENT_SECRET - Twitter verification
  • TIKTOK_CLIENT_ID / TIKTOK_CLIENT_SECRET - TikTok verification
  • LINKEDIN_CLIENT_ID / LINKEDIN_CLIENT_SECRET - LinkedIn verification
  • YOUTUBE_API_KEY - YouTube verification
  • SCRAPECREATORS_API_KEY - Creator scraping service
  • PAYPAL_CLIENT_ID / PAYPAL_CLIENT_SECRET / PAYPAL_WEBHOOK_ID - PayPal integration
  • STRIPE_APP_SECRET_KEY_TEST / STRIPE_APP_SECRET_KEY / STRIPE_APP_SECRET_KEY_SANDBOX - Stripe app keys
  • FIRECRAWL_API_KEY - Program lander generation
  • SINGULAR_WEBHOOK_TOKEN - Singular events
  • HUBSPOT_CLIENT_ID / HUBSPOT_CLIENT_SECRET - HubSpot integration

Environment File Template

Here’s a minimal .env template to get started:
# Application
NEXT_PUBLIC_APP_NAME=Dub
NEXT_PUBLIC_APP_DOMAIN=yourdomain.com
NEXT_PUBLIC_APP_SHORT_DOMAIN=short.yourdomain.com

# Database
DATABASE_URL="mysql://user:password@host:3306/dub"

# Authentication
NEXTAUTH_SECRET=your-super-secret-key-minimum-32-characters
NEXTAUTH_URL=https://yourdomain.com

# Tinybird Analytics
TINYBIRD_API_KEY=p.ey...
TINYBIRD_API_URL=https://api.tinybird.co

# Vercel Domains API
PROJECT_ID_VERCEL=prj_...
TEAM_ID_VERCEL=team_...
AUTH_BEARER_TOKEN=...

# Upstash Redis
UPSTASH_REDIS_REST_URL=https://....upstash.io
UPSTASH_REDIS_REST_TOKEN=...

# Upstash QStash
QSTASH_TOKEN=...
QSTASH_CURRENT_SIGNING_KEY=...
QSTASH_NEXT_SIGNING_KEY=...

# Email (Choose Resend OR SMTP)
RESEND_API_KEY=re_...
# OR for local development:
# SMTP_HOST=localhost
# SMTP_PORT=1025

Validation

To verify your environment configuration:
  1. Check that all required variables are set
  2. Test database connectivity with pnpm prisma:studio
  3. Verify Redis connection by starting the dev server
  4. Test email delivery by signing up for an account
Missing required environment variables will cause the application to fail at startup with clear error messages indicating which variables are missing.

Build docs developers (and LLMs) love