Skip to main content

Environment Variables

This starter uses environment variables for all configuration. Copy .env.example to .env and fill in the values relevant to your setup. For local overrides, create .env.local (loaded with higher priority).

cp .env.example .env

Variable Reference

Database

VariableRequiredDefaultDescription
DATABASE_URLYes--PostgreSQL connection string, e.g. postgresql://user:pass@localhost:5432/myapp

Authentication

VariableRequiredDefaultDescription
JWT_SECRETYes--Signing key for access tokens. Minimum 32 characters.
JWT_REFRESH_SECRETYes--Signing key for refresh tokens. Minimum 32 characters. Use a different value than JWT_SECRET.
GOOGLE_CLIENT_IDNo--Google OAuth 2.0 client ID. Required only if you enable Google login.
GOOGLE_CLIENT_SECRETNo--Google OAuth 2.0 client secret.

Billing (Stripe)

STRIPE_SECRET_KEY and STRIPE_WEBHOOK_SECRET are validated by the Zod config schema at startup. The API will not start without them. Use Stripe test keys for local development.

VariableRequiredDefaultDescription
STRIPE_SECRET_KEYYes--Stripe secret API key (starts with sk_). Use sk_test_... locally.
STRIPE_WEBHOOK_SECRETYes--Stripe webhook signing secret (starts with whsec_). Use stripe listen to get a test value.
STRIPE_PUBLISHABLE_KEYNo--Stripe publishable key (starts with pk_). Returned by GET /billing/config.
STRIPE_PRICENo--Stripe Price ID for the subscription plan. Returned by GET /billing/config.

Email

VariableRequiredDefaultDescription
RESEND_API_KEYNo--API key for Resend transactional email. When absent, emails are logged to the console.
EMAIL_FROMNohello@example.comSender address for outgoing emails.

Storage (AWS S3)

VariableRequiredDefaultDescription
AWS_S3_BUCKETNo--S3 bucket name for file uploads.
AWS_REGIONNo--AWS region for the S3 bucket.
AWS_ACCESS_KEY_IDNo--AWS IAM access key ID.
AWS_SECRET_ACCESS_KEYNo--AWS IAM secret access key.

Queue

VariableRequiredDefaultDescription
REDIS_URLNo--Redis connection string for BullMQ background jobs, e.g. redis://localhost:6379.

Application

VariableRequiredDefaultDescription
APP_URLNohttp://localhost:5173Frontend URL. Used for CORS configuration and email links.
API_URLNohttp://localhost:4000API base URL. Used in generated links and documentation.
PORTNo4000Port the API server listens on.

Minimal local setup

For local development, you need five variables to start the API:

DATABASE_URL=postgresql://user:pass@localhost:5432/myapp
JWT_SECRET=your-random-string-at-least-32-chars
JWT_REFRESH_SECRET=another-random-string-at-least-32-chars
STRIPE_SECRET_KEY=sk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...

STRIPE_SECRET_KEY and STRIPE_WEBHOOK_SECRET are enforced by the config schema — the API will not start without them. Use Stripe test keys and run stripe listen --forward-to localhost:4000/billing/webhook to get a local signing secret.

Everything else (RESEND_API_KEY, AWS S3, Redis, Google OAuth) is optional and the application degrades gracefully when absent. Emails are logged to stdout when RESEND_API_KEY is not set.

Generating secrets

Use openssl to generate cryptographically secure random strings:

openssl rand -base64 32

Run this twice -- once for JWT_SECRET and once for JWT_REFRESH_SECRET.