Environment Variables Reference
Complete reference for every environment variable used by BloggFast.
Last updated:
Note
Copy
.env.example to .env as your starting point. Never commit .env to version control. All variables are validated on startup via @t3-oss/env-nextjs — missing required variables will cause a descriptive build/startup error.Database variables
| Variable | Purpose | Required | Notes |
|---|---|---|---|
DATABASE_URL | Neon Postgres pooled connection string (via pgBouncer) | Yes | Used for runtime queries. Must include channel_binding=require&sslmode=require for Neon |
DATABASE_URL_UNPOOLED | Direct (non-pooled) connection string for Prisma migrations | Yes | Required for prisma migrate dev and db:seed. Use the endpoint without -pooler in the hostname |
PGHOST | Postgres host (pooled) — for Neon dashboard use | No | Optional convenience variable provided by Neon |
PGHOST_UNPOOLED | Postgres host (direct) — for Neon dashboard use | No | Optional convenience variable provided by Neon |
PGUSER | Postgres username | No | Optional — already included in the connection strings |
PGDATABASE | Postgres database name | No | Typically neondb |
PGPASSWORD | Postgres password | No | Optional — already included in the connection strings |
.env
# Pooled connection (use for runtime queries)
DATABASE_URL=postgresql://user:pass@ep-xxx-pooler.region.aws.neon.tech/neondb?channel_binding=require&sslmode=require
# Direct connection (use for Prisma migrations and seeding)
DATABASE_URL_UNPOOLED=postgresql://user:pass@ep-xxx.region.aws.neon.tech/neondb?sslmode=requireNeon Auth variables
| Variable | Purpose | Required |
|---|---|---|
NEON_AUTH_BASE_URL | Neon Auth endpoint URL — provided by Neon when you enable Auth on your project | Yes |
NEON_AUTH_COOKIE_SECRET | Secret key used to sign session cookies — must be at least 32 characters | Yes |
.env
# From your Neon project → Auth tab
NEON_AUTH_BASE_URL="https://ep-xxx.neonauth.region.aws.neon.tech/neondb/auth"
NEON_AUTH_COOKIE_SECRET="a-long-random-secret-string-of-at-least-32-characters"Tip
Find these values in your Neon project dashboard under the Auth tab after enabling Neon Auth. The base URL format is specific to your Neon project endpoint.
Sanity CMS variables
| Variable | Purpose | Required | Example |
|---|---|---|---|
NEXT_PUBLIC_SANITY_PROJECT_ID | Your Sanity project ID (public — exposed to browser) | Yes | pup1pp2q |
NEXT_PUBLIC_SANITY_DATASET | Sanity dataset name (public — exposed to browser) | Yes | production |
SANITY_API_TOKEN | Server-side Sanity API token with Editor permissions | Yes | sk... |
SANITY_TOKEN_ARTICLE_UPLOADER | Separate Sanity token used when the AI generator publishes articles to Sanity | No | sk... |
SANITY_WEBHOOK_SECRET | Secret for validating Sanity webhook payloads (cache revalidation) | No | Any random string |
.env
NEXT_PUBLIC_SANITY_PROJECT_ID=your_project_id
NEXT_PUBLIC_SANITY_DATASET=production
SANITY_API_TOKEN=sk...
SANITY_TOKEN_ARTICLE_UPLOADER=sk... # Optional: separate write token for AI article uploadsVercel AI Gateway variable
| Variable | Purpose | Required | Notes |
|---|---|---|---|
AI_GATEWAY_API_KEY | Vercel AI Gateway key used for all article text and cover image generation | Yes | Create from your Vercel project → AI Gateway tab → Create Key. Key starts with vck_ |
.env
AI_GATEWAY_API_KEY=vck_...Note
BloggFast routes every AI call through the Vercel AI Gateway, so one key unlocks Anthropic, Google, and OpenAI models. Defaults are
claude-sonnet-4.6 for text and flux-2-pro for cover images. Active models are stored in the AiSettings record and can be changed from /admin/settings. Vercel grants $5 of free gateway credits on signup.Resend email variables
| Variable | Purpose | Required | Example |
|---|---|---|---|
RESEND_API_KEY | Resend API key for sending emails | Yes | re_... |
RESEND_FROM_EMAIL | Sender address for outgoing emails (must be a verified domain in Resend) | Yes | hello@yourdomain.com |
RESEND_WEBHOOK_SECRET | Webhook signing secret for verifying Resend event deliveries (bounced, complained, etc.) | No | whsec_... |
RESEND_AUDIENCE_ID | Resend Audience ID for contact list sync — if set, subscribers are added to this Resend Audience | No | UUID from Resend Audiences dashboard |
.env
RESEND_API_KEY=re_...
RESEND_FROM_EMAIL=hello@yourdomain.com
RESEND_WEBHOOK_SECRET=whsec_... # Optional
RESEND_AUDIENCE_ID= # OptionalNote
During development, you can use
onboarding@resend.dev as the from address without domain verification, but it only sends to the account email. For production, verify your own domain in the Resend dashboard under Domains.Cloudflare R2 variables
BloggFast uses Cloudflare R2 (via the AWS S3 SDK) to store article cover images, AI-generated images, and per-user skill files.
| Variable | Purpose | Required |
|---|---|---|
CLOUDFLARE_ACCOUNT_ID | Your Cloudflare account ID (R2 Overview → Account details) | Yes |
R2_BUCKET_NAME | The R2 bucket created for this project | Yes |
R2_ENDPOINT | S3 API endpoint, e.g. https://{account}.r2.cloudflarestorage.com | Yes |
R2_ACCESS_KEY_ID | Access key from an R2 account API token with Admin Read & Write | Yes |
R2_SECRET_ACCESS_KEY | Secret key paired with the access key above | Yes |
R2_PUBLIC_BASE_URL | Public URL served via your custom domain — leave empty until you attach one | No |
R2_PUBLIC_DEVELOPMENT_URL | Public Development URL generated when you enable it in the bucket settings | Yes |
NEXT_PUBLIC_MAX_UPLOAD_MB | Upload size cap (MB) applied client-side; e.g. 100 | Yes |
.env
CLOUDFLARE_ACCOUNT_ID=your_cloudflare_account_id
R2_BUCKET_NAME=bloggfast-storage
R2_ENDPOINT=https://your_account_id.r2.cloudflarestorage.com
R2_ACCESS_KEY_ID=your_r2_access_key_id
R2_SECRET_ACCESS_KEY=your_r2_secret_access_key
R2_PUBLIC_BASE_URL=
R2_PUBLIC_DEVELOPMENT_URL=https://pub-xxx.r2.dev
NEXT_PUBLIC_MAX_UPLOAD_MB=100Site variables
| Variable | Purpose | Required | Example |
|---|---|---|---|
NEXT_PUBLIC_SITE_URL | Full public URL of your site — used for generating absolute URLs (OG images, sitemaps) | Yes | https://myblog.com |
NEXT_PUBLIC_APP_URL | App base URL — used for internal routing and API endpoint construction | Yes | https://myblog.com or your Vercel domain |
.env
# Development
NEXT_PUBLIC_SITE_URL="http://localhost:3000"
NEXT_PUBLIC_APP_URL="http://localhost:3000"
# Production (set in Vercel dashboard)
NEXT_PUBLIC_SITE_URL="https://myblog.com"
NEXT_PUBLIC_APP_URL="https://myblog.com"