Environment Setup
Configure environment variables for your LaunchSaaS application
LaunchSaaS requires several environment variables to function properly. This guide explains how to set them up.
Create a .env file in the root directory of your project, and never commit it to version control.
cp .env.example .envEnvironment Variables
Core Configuration
| Variable | Description |
|---|---|
NEXT_PUBLIC_APP_URL | Your site URL (e.g., http://localhost:3000 for dev, https://yourdomain.com for prod) |
Next.js automatically loads .env.development during development and .env.production for production builds.
Database
Learn how to set up a database in the Database Setup guide.
| Variable | Description |
|---|---|
DATABASE_TYPE | Database type: postgresql (default) or mysql |
DATABASE_URL | Database connection URL |
Authentication
Learn how to set up authentication in the Authentication Setup guide.
| Variable | Description |
|---|---|
BETTER_AUTH_SECRET | A random 32+ character string for encryption. Generate with VictoryHub |
NEXT_PUBLIC_GOOGLE_CLIENT_ID | Google OAuth client ID (optional) |
GOOGLE_CLIENT_SECRET | Google OAuth client secret (optional) |
NEXT_PUBLIC_GITHUB_CLIENT_ID | GitHub OAuth client ID (optional) |
GITHUB_CLIENT_SECRET | GitHub OAuth client secret (optional) |
Admin User
| Variable | Description |
|---|---|
ADMIN_EMAIL | Admin email address |
ADMIN_PASSWORD | Admin password |
Email (Optional)
Learn how to set up email in the Email Setup guide.
| Variable | Description |
|---|---|
RESEND_API_KEY | API key from Resend |
RESEND_FROM_EMAIL | Sender email (use [email protected] for testing) |
Newsletter (Optional)
Learn how to set up newsletter in the Newsletter Setup guide.
| Variable | Description |
|---|---|
RESEND_AUDIENCE_NEWSLETTER | Resend Audience ID for newsletter (optional) |
RESEND_AUDIENCE_WAITLIST | Resend Audience ID for waitlist (optional) |
Payment - Stripe (Optional)
Learn how to set up payments in the Payment Setup guide.
| Variable | Description |
|---|---|
STRIPE_SECRET_KEY | Stripe secret key (sk_test_... or sk_live_...) |
STRIPE_WEBHOOK_SECRET | Stripe webhook signing secret (whsec_...) |
Payment - Creem (Optional)
Learn how to set up Creem in the Payment Setup guide.
| Variable | Description |
|---|---|
CREEM_API_KEY | Creem API key |
CREEM_WEBHOOK_SECRET | Creem webhook signing secret |
Captcha (Optional)
| Variable | Description |
|---|---|
NEXT_PUBLIC_CAPTCHA_PUBLIC_KEY | Captcha site key |
CAPTCHA_SECRET_KEY | Captcha secret key |
Storage (Optional)
Learn how to set up storage in the Storage Setup guide.
| Variable | Description |
|---|---|
S3_REGION | S3 region |
S3_BUCKET | S3 bucket name |
S3_ACCESS_KEY_ID | S3 access key ID |
S3_SECRET_ACCESS_KEY | S3 secret access key |
S3_API_ENDPOINT | S3 API endpoint |
S3_PUBLIC_ENDPOINT | S3 public endpoint URL |
Cache (Optional)
Learn how to set up cache in the Cache Setup guide.
Redis (Standard)
For local Redis or managed Redis services (AWS ElastiCache, Azure Cache, etc.).
| Variable | Description |
|---|---|
REDIS_URL | Redis connection URL (e.g., redis://localhost:6379 or rediss://...) |
Upstash Redis
For Upstash Redis using HTTP REST API (perfect for serverless).
| Variable | Description |
|---|---|
UPSTASH_REDIS_REST_URL | Upstash Redis REST endpoint |
UPSTASH_REDIS_REST_TOKEN | Upstash Redis REST token |
Cloudflare KV
| Variable | Description |
|---|---|
CLOUDFLARE_ACCOUNT_ID | Cloudflare Account ID |
CLOUDFLARE_KV_NAMESPACE_ID | Cloudflare KV Namespace ID |
CLOUDFLARE_API_TOKEN | Cloudflare API Token |
Scheduled Jobs (Optional)
Learn how to set up scheduled jobs in the Scheduled Jobs Setup guide.
Upstash QStash
| Variable | Description |
|---|---|
QSTASH_URL | QStash API base URL (optional, has default) |
QSTASH_TOKEN | QStash API token |
QSTASH_CURRENT_SIGNING_KEY | QStash current webhook signing key |
QSTASH_NEXT_SIGNING_KEY | QStash next webhook signing key (for rotation) |
Analytics (Optional)
| Variable | Description |
|---|---|
NEXT_PUBLIC_GOOGLE_ANALYTICS_ID | Google Analytics ID |
NEXT_PUBLIC_OPENPANEL_CLIENT_ID | OpenPanel client ID |
NEXT_PUBLIC_PLAUSIBLE_DOMAIN | Plausible domain |
NEXT_PUBLIC_UMAMI_WEBSITE_ID | Umami website ID |
NEXT_PUBLIC_UMAMI_URL | Umami script URL |
NEXT_PUBLIC_POSTHOG_KEY | PostHog API key |
NEXT_PUBLIC_POSTHOG_HOST | PostHog host URL |
NEXT_PUBLIC_VERCEL_ANALYTICS_ENABLED | Enable Vercel Analytics (true / false) |
NEXT_PUBLIC_AHREFS_ANALYTICS_ID | Ahrefs Analytics ID |
GitHub Integration (Optional)
For automatic repository access on payment completion. Enable in packages/config/src/features/development.ts or packages/config/src/features/production.ts.
| Variable | Description |
|---|---|
GITHUB_TOKEN | GitHub Personal Access Token with admin:org and repo scopes |
GITHUB_REPO | Repository in format owner/repo |
Feature Configuration
LaunchSaaS uses packages/config/src/features/ to control which providers are enabled:
// packages/config/src/features/development.ts
export const features: Features = {
email: {
provider: "resend",
},
newsletter: {
provider: "resend",
},
authentication: {
magicLink: true,
captcha: {
enabled: true,
provider: "cloudflare-turnstile",
},
oauths: {
google: true,
github: true,
},
},
payment: {
provider: "stripe", // "stripe" | "creem"
hooks: {
github: true, // Enable GitHub integration
email: true, // Enable payment completion emails
},
},
};packages/config/src/features/index.ts loads production.ts only when NODE_ENV === "production". All other environments use development.ts.
Omit optional sections such as storage, cache, cron, newsletter, or payment when you do not want to enable that feature in the active environment file.
Learn more in the Features Configuration guide.
Verifying Environment Variables
To verify that your environment variables are correctly set up, run:
pnpm run devIf everything is configured correctly, your application should start without any environment-related errors.