Documentation

Environment Setup

Configure environment variables for your Dirstarter application

Dirstarter requires several environment variables to function properly. This guide explains how to set them up.

Setup

Create a .env file in the root directory of your project. You can copy the example file as a starting point:

terminal
cp .env.example .env

Never commit your .env file to version control. It contains sensitive information that should be kept private.

Environment Variables

Core Configuration

VariableDescription
NEXT_PUBLIC_SITE_URLThe public URL of your site (e.g., http://localhost:3000 for development)
NEXT_PUBLIC_SITE_EMAILThe contact email for your site

Cron Jobs

Learn how to set up cron jobs in the Cron Jobs guide.

VariableDescription
CRON_SECRETA random string used to secure cron jobs

Database

Learn how to set up a database in the Database Setup guide.

VariableDescription
DATABASE_URLPostgreSQL database connection URL

Authentication

Learn how to set up authentication in the Authentication guide.

VariableDescription
BETTER_AUTH_SECRETA random string used to hash tokens and sign cookies
BETTER_AUTH_URLThe URL of your site (same as NEXT_PUBLIC_SITE_URL)
AUTH_GOOGLE_IDGoogle OAuth client ID
AUTH_GOOGLE_SECRETGoogle OAuth client secret

Redis

Learn how to set up Redis in the Rate Limiting guide.

VariableDescription
REDIS_REST_URL (optional)Redis REST URL
REDIS_REST_TOKEN (optional)Redis REST token

Email Service

Learn how to set up an Resend email service in the Email guide.

VariableDescription
RESEND_API_KEYAPI key for Resend email service
RESEND_SENDER_EMAILDefault sender email address
RESEND_AUDIENCE_IDAudience ID for Resend marketing email service

Storage

Learn how to set up a S3 storage service in the Storage guide.

VariableDescription
S3_BUCKETName of your S3 bucket
S3_REGIONAWS region for your S3 bucket
S3_ACCESS_KEYAWS access key ID
S3_SECRET_ACCESS_KEYAWS secret access key

Analytics

Learn how to set up an analytics service in the Analytics guide.

VariableDescription
NEXT_PUBLIC_POSTHOG_HOSTPostHog instance URL
NEXT_PUBLIC_POSTHOG_API_KEYPostHog API key
NEXT_PUBLIC_PLAUSIBLE_DOMAINYour Plausible domain
NEXT_PUBLIC_PLAUSIBLE_URLPlausible instance URL
PLAUSIBLE_API_KEYPlausible API key

AI & Web Scraping

Learn how to set up an AI and web scraping service in the Automation guide or use the Media guide.

VariableDescription
GOOGLE_GENERATIVE_AI_API_KEYGoogle Gemini API key for AI features
JINA_API_KEY (optional)Jina API key for web scraping
SCREENSHOTONE_ACCESS_KEYScreenshotOne API key

Payments

Learn how to set up a payment service in the Payments guide.

VariableDescription
STRIPE_SECRET_KEYStripe secret key
STRIPE_WEBHOOK_SECRETStripe webhook signing secret
STRIPE_PRODUCT_IDSComma-separated list of Stripe product IDs

Type-Safe Validation

Dirstarter uses the T3 Env package for type-safe environment variable validation. The validation is configured in env.ts and ensures that:

  • All required environment variables are present
  • Variables have the correct type (string, number, etc.)
  • URLs are properly formatted
  • Email addresses are valid
  • No empty strings are allowed (they're treated as undefined)

To skip validation during builds (useful for Docker), set SKIP_ENV_VALIDATION flag:

Terminal
npm run build SKIP_ENV_VALIDATION=1

Environment-Specific Variables

Development Environment

For development, you can use local services or development credentials:

.env
NEXT_PUBLIC_SITE_URL="http://localhost:3000"
BETTER_AUTH_URL="http://localhost:3000"

Production Environment

For production, use secure, production-ready services and ensure all required variables are set with proper values.

Verifying Your Environment

To verify that your environment variables are correctly set up, run:

Terminal
npm run dev

If everything is configured correctly, your application should start without any environment-related errors.

What's Next?

Now that your environment is set up, learn how to create your first directory entry in the First Steps guide.

Edit on GitHub

Last updated on

On this page