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:
cp .env.example .envNever commit your .env file to version control. It contains sensitive information that should be kept private.
Environment Variables
Core Configuration
| Variable | Description |
|---|---|
NEXT_PUBLIC_SITE_URL | The public URL of your site (e.g., http://localhost:3000 for development) |
NEXT_PUBLIC_SITE_EMAIL | The contact email for your site |
Cron Jobs
Learn how to set up cron jobs in the Cron Jobs guide.
| Variable | Description |
|---|---|
CRON_SECRET | A random string used to secure cron jobs |
Database
Learn how to set up a database in the Database Setup guide.
| Variable | Description |
|---|---|
DATABASE_URL | PostgreSQL database connection URL |
Authentication
Learn how to set up authentication in the Authentication guide.
| Variable | Description |
|---|---|
BETTER_AUTH_SECRET | A random string used to hash tokens and sign cookies |
BETTER_AUTH_URL | The URL of your site (same as NEXT_PUBLIC_SITE_URL) |
AUTH_GOOGLE_ID | Google OAuth client ID |
AUTH_GOOGLE_SECRET | Google OAuth client secret |
Redis
Learn how to set up Redis in the Rate Limiting guide.
| Variable | Description |
|---|---|
REDIS_URL (optional) | Redis connection URL (format: redis://[username:password@]host:port). Falls back to in-memory rate limiting if not set. |
Email Service
Learn how to set up an Resend email service in the Email guide.
| Variable | Description |
|---|---|
RESEND_API_KEY | API key for Resend email service |
RESEND_SENDER_EMAIL | Default sender email address |
RESEND_AUDIENCE_ID | Audience ID for Resend marketing email service |
Storage
Learn how to set up a S3 storage service in the Storage guide.
| Variable | Description |
|---|---|
S3_BUCKET | Name of your S3 bucket |
S3_REGION | AWS region for your S3 bucket |
S3_ACCESS_KEY | AWS access key ID |
S3_SECRET_ACCESS_KEY | AWS secret access key |
Analytics
Learn how to set up an analytics service in the Analytics guide.
| Variable | Description |
|---|---|
NEXT_PUBLIC_PLAUSIBLE_DOMAIN | Your Plausible domain |
NEXT_PUBLIC_PLAUSIBLE_URL | Plausible instance URL |
PLAUSIBLE_API_KEY | Plausible 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.
| Variable | Description |
|---|---|
GOOGLE_GENERATIVE_AI_API_KEY | Google Gemini API key for AI features |
JINA_API_KEY (optional) | Jina API key for web scraping |
SCREENSHOTONE_ACCESS_KEY | ScreenshotOne API key |
Payments
Learn how to set up a payment service in the Payments guide.
| Variable | Description |
|---|---|
STRIPE_SECRET_KEY | Stripe secret key |
STRIPE_WEBHOOK_SECRET | Stripe webhook signing secret |
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:
npm run build SKIP_ENV_VALIDATION=1Environment-Specific Variables
Development Environment
For development, you can use local services or development credentials:
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:
npm run devIf 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.
Last updated on