Skip to Content
Getting StartedEnvironment Setup

Environment Setup

Copy .env.example to .env in the project root, then set the variables below. The app validates env at build and runtime via src/env.ts; invalid or missing required vars will cause errors.

For Docker or CI builds where not all vars are available at build time, set SKIP_ENV_VALIDATION=1 to skip validation.

Payload & database

VariableRequiredDescription
PAYLOAD_SECRETYesSecret used for signing; must be set and kept private
DATABASE_PUBLIC_URIYesMongoDB (or DB) connection string for general use
DATABASE_PRIVATE_URIYesPrivate / server-side connection string
DATABASE_NAMENoDatabase name (Payload can use default if omitted)
PREVIEW_SECRETNoOptional secret for draft preview

Auth (Better Auth)

VariableRequiredDescription
BETTER_AUTH_URLNoBase URL of your app (e.g. https://yoursite.com)
GOOGLE_CLIENT_IDNoGoogle OAuth client ID
GOOGLE_CLIENT_SECRETNoGoogle OAuth client secret

Stripe

VariableRequiredDescription
STRIPE_SECRET_KEYYesStripe secret key (when Stripe plugin is enabled)
STRIPE_WEBHOOKS_ENDPOINT_SECRETYesWebhook signing secret for your Stripe endpoint

S3 (optional)

When all of these are set, the S3 storage adapter is used for media uploads.

VariableRequiredDescription
S3_BUCKETNoS3 bucket name
S3_ACCESS_KEY_IDNoAccess key
S3_SECRET_ACCESS_KEYNoSecret key
S3_REGIONNoAWS region
S3_PREFIX_ROOTFOLDERNoOptional path prefix in the bucket

Email

VariableRequiredDescription
EMAIL_ADAPTERYesresend (Resend REST API) or smtp (Nodemailer). Use resend on Railway (no SMTP egress).
RESEND_API_KEYWhen resendRequired if EMAIL_ADAPTER=resend. Optional for smtp (used as SMTP password with Resend SMTP).
EMAIL_FROMNoDefault “from” address
EMAIL_FROM_NAMENoDefault “from” name
EMAIL_SMTP_HOSTNoSMTP host (default: smtp.resend.com) — only for smtp
EMAIL_SMTP_PORTNoSMTP port (default: 465) — only for smtp
EMAIL_SMTP_USERNoSMTP user (default: resend) — only for smtp
EMAIL_SMTP_PASSNoSMTP password — only for smtp

See Email for full setup (Resend API vs SMTP, Railway).

Client-side (optional)

These are exposed to the browser; only set what you need.

VariableRequiredDescription
NEXT_PUBLIC_SERVER_URLNoPublic URL of the server
NEXT_PUBLIC_BETTER_AUTH_URLNoAuth base URL for the client
NEXT_PUBLIC_GOOGLE_CLIENT_IDNoGoogle client ID for OAuth
NEXT_PUBLIC_GA_IDNoGoogle Analytics ID