Skip to main content

Overview

Reportr requires several environment variables to be configured for proper operation. Copy .env.example to .env and configure all required values.
cp .env.example .env

Required Variables

Database

DATABASE_URL
string
required
PostgreSQL connection string for the database. Used for direct connections.Format: postgresql://username:password@host:port/databaseExample: postgresql://postgres:password@localhost:5432/seo_reportbot
PRISMA_DATABASE_URL
string
Alternative database URL used by Prisma for connection pooling (e.g., via Supabase or PgBouncer).If not specified, Prisma will use DATABASE_URL.

Authentication

NEXTAUTH_SECRET
string
required
Secret key used to encrypt NextAuth.js JWT tokens and session data.Generate with: openssl rand -base64 32Example: your-nextauth-secret-here
NEXTAUTH_URL
string
required
The canonical URL of your application. Used by NextAuth.js for redirects.Development: http://localhost:3000Production: https://yourdomain.com
NEXT_PUBLIC_APP_URL
string
required
Public-facing URL accessible from the client-side. Must match NEXTAUTH_URL.Example: http://localhost:3000

Google OAuth & APIs

GOOGLE_CLIENT_ID
string
required
OAuth 2.0 Client ID from Google Cloud Console. Used for user authentication and API access.Get from: Google Cloud Console > APIs & Services > Credentials
GOOGLE_CLIENT_SECRET
string
required
OAuth 2.0 Client Secret from Google Cloud Console.Security: Never commit this to version control.
GOOGLE_REDIRECT_URI
string
required
OAuth callback URL that Google redirects to after authentication.Example: http://localhost:3000/api/auth/callback/googleImportant: Must match exactly with the URI configured in Google Cloud Console.
PAGESPEED_API_KEY
string
required
API key for Google PageSpeed Insights API. Used to fetch performance metrics.Get from: Google Cloud Console > APIs & Services > Credentials > Create API Key

AI Services

ANTHROPIC_API_KEY
string
required
API key for Anthropic’s Claude API. Used to generate AI-powered insights in reports.Get from: Anthropic ConsoleFormat: sk-ant-...

Queue System

UPSTASH_REDIS_REST_URL
string
required
REST API URL for Upstash Redis. Used for background job processing and queue management.Get from: Upstash Console after creating a Redis databaseExample: https://us1-example.upstash.io
UPSTASH_REDIS_REST_TOKEN
string
required
Authentication token for Upstash Redis REST API.Security: Keep this secret and never expose in client-side code.

File Storage

BLOB_READ_WRITE_TOKEN
string
required
Vercel Blob storage token for storing generated PDF reports.Get from: Vercel Dashboard > Storage > Blob > Create TokenFormat: vercel_blob_rw_...

Payment Processing (Optional)

Stripe

STRIPE_SECRET_KEY
string
Stripe secret key for processing payments and managing subscriptions.Get from: Stripe Dashboard > Developers > API KeysDevelopment: Use test key sk_test_...Production: Use live key sk_live_...
STRIPE_WEBHOOK_SECRET
string
Webhook signing secret for verifying Stripe webhook events.Get from: Stripe Dashboard > Developers > Webhooks > Add endpointFormat: whsec_...

PayPal

PAYPAL_CLIENT_ID
string
PayPal REST API client ID for payment processing.Get from: PayPal Developer Dashboard
PAYPAL_CLIENT_SECRET
string
PayPal REST API client secret.
PAYPAL_MODE
string
PayPal environment mode.Options: sandbox (development) or live (production)Default: sandbox
PAYPAL_WEBHOOK_ID
string
Webhook ID for verifying PayPal webhook signatures in production.Get from: PayPal Developer Dashboard > Apps & Credentials > Webhooks

PayPal Plan IDs

Subscription plan IDs for different tiers. These are server-side only:
PAYPAL_STARTER_TRIAL_PLAN_ID
string
Starter plan with trial period.
PAYPAL_STARTER_DIRECT_PLAN_ID
string
Starter plan without trial.
PAYPAL_PRO_TRIAL_PLAN_ID
string
Professional plan with trial period.
PAYPAL_PRO_DIRECT_PLAN_ID
string
Professional plan without trial.
PAYPAL_AGENCY_TRIAL_PLAN_ID
string
Agency plan with trial period.
PAYPAL_AGENCY_DIRECT_PLAN_ID
string
Agency plan without trial.

Public PayPal Plan IDs

Client-side accessible plan IDs (prefixed with NEXT_PUBLIC_):
NEXT_PUBLIC_PAYPAL_STARTER_TRIAL_PLAN_ID
string
Public version of Starter trial plan ID.
NEXT_PUBLIC_PAYPAL_STARTER_DIRECT_PLAN_ID
string
Public version of Starter direct plan ID.
NEXT_PUBLIC_PAYPAL_PRO_TRIAL_PLAN_ID
string
Public version of Professional trial plan ID.
NEXT_PUBLIC_PAYPAL_PRO_DIRECT_PLAN_ID
string
Public version of Professional direct plan ID.
NEXT_PUBLIC_PAYPAL_AGENCY_TRIAL_PLAN_ID
string
Public version of Agency trial plan ID.
NEXT_PUBLIC_PAYPAL_AGENCY_DIRECT_PLAN_ID
string
Public version of Agency direct plan ID.

Email Service

RESEND_API_KEY
string
API key for Resend email service. Used for sending transactional emails.Get from: Resend DashboardFormat: re_...
FROM_EMAIL
string
Email address used as the sender for outgoing emails.Example: [email protected]Note: Must be verified in Resend dashboard.
REPLY_TO_EMAIL
string
Reply-to email address for user responses.Example: [email protected]

Security

CRON_SECRET
string
Secret token for authenticating cron job requests. Prevents unauthorized execution.Generate with: openssl rand -base64 32Example: PiVKrJew9gQyWTohW/LiUV3J+xZPFIC7UkXrqLXoFgI=

Example .env File

# Database
DATABASE_URL="postgresql://postgres:password@localhost:5432/seo_reportbot"

# NextAuth.js
NEXTAUTH_SECRET="your-nextauth-secret-here"
NEXTAUTH_URL="http://localhost:3000"
NEXT_PUBLIC_APP_URL="http://localhost:3000"

# Google OAuth & APIs
GOOGLE_CLIENT_ID="your-google-client-id"
GOOGLE_CLIENT_SECRET="your-google-client-secret"
GOOGLE_REDIRECT_URI="http://localhost:3000/api/auth/callback/google"
PAGESPEED_API_KEY="your-pagespeed-api-key"

# AI Services
ANTHROPIC_API_KEY="sk-ant-your-api-key-here"

# Queue System
UPSTASH_REDIS_REST_URL="https://..."
UPSTASH_REDIS_REST_TOKEN="..."

# File Storage
BLOB_READ_WRITE_TOKEN="vercel_blob_rw_..."

# Cron Security
CRON_SECRET="your-random-secret-here"

Environment-Specific Configuration

Development

For local development:
  • Use http://localhost:3000 for all URL variables
  • Use Stripe test keys (sk_test_...)
  • Use PayPal sandbox mode
  • Database can be local PostgreSQL

Production

For production deployment:
  • Use your production domain for URL variables
  • Use Stripe live keys (sk_live_...)
  • Set PayPal mode to live
  • Use a managed PostgreSQL service (Vercel Postgres, Supabase, etc.)
  • Enable all security features
  • Verify all webhook endpoints are configured

Security Best Practices

Never commit your .env file to version control. The .env.example file should only contain variable names, not actual values.
  1. Use strong secrets: Generate random strings for all secret keys
  2. Rotate credentials regularly: Update API keys and secrets periodically
  3. Limit access: Only share credentials with team members who need them
  4. Use environment-specific keys: Different keys for dev, staging, and production
  5. Monitor usage: Check API usage and logs for suspicious activity

Verifying Configuration

After setting up your environment variables:
  1. Restart your development server
  2. Check the application logs for connection errors
  3. Test authentication by signing in with Google
  4. Verify database connectivity with npm run db:studio
  5. Test API integrations in the dashboard

Troubleshooting

Variable Not Loading

If an environment variable is not being recognized:
  1. Verify the variable name matches exactly (case-sensitive)
  2. Restart your development server after changes
  3. Check for syntax errors in .env (no spaces around =)
  4. Ensure client-side variables start with NEXT_PUBLIC_

Database Connection Failed

If database connection fails:
  1. Verify DATABASE_URL format is correct
  2. Check PostgreSQL is running
  3. Test connection with psql command
  4. Ensure database exists: createdb seo_reportbot

OAuth Errors

If Google OAuth fails:
  1. Verify GOOGLE_REDIRECT_URI matches Google Cloud Console configuration
  2. Check NEXTAUTH_URL and NEXT_PUBLIC_APP_URL are identical
  3. Ensure Google OAuth consent screen is configured
  4. Verify all required scopes are enabled

Build docs developers (and LLMs) love