Environment Variables

Create a .env file in the root of the project. The variables marked Required must be set before the app will start. All others are optional depending on which features you enable.

VariableRequiredDescription
DATABASE_URLRequiredPostgreSQL connection string. For production on DigitalOcean Managed DB, append &connection_limit=5 to cap the Prisma pool per instance.
e.g. postgresql://user:password@localhost:5432/mydb?connection_limit=5
NEXTAUTH_URLRequiredCanonical URL of your deployment. Must match the domain exactly.
e.g. https://yourstore.com
NEXTAUTH_SECRETRequiredA random secret string used to sign session tokens. Generate one with: openssl rand -base64 32
e.g. your-random-secret
APP_ENCRYPTION_KEYRequired64-character hex key used to encrypt payment and shipping provider credentials stored in the database. Generate with: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
ADMIN_EMAILSRequiredComma-separated list of email addresses that are automatically assigned the ADMIN role when they sign up or sign in for the first time.
NEXT_PUBLIC_SITE_URLRequiredPublic-facing site URL, baked into the client bundle at build time. Used for canonical links, sitemap generation, and OG images.
e.g. https://yourstore.com
SITE_URLOptionalServer-side site URL. Used to derive NEXTAUTH_URL when that variable is not set explicitly. Typically the same value as NEXT_PUBLIC_SITE_URL.
e.g. https://yourstore.com
SITE_NAMEOptionalDisplay name for the site, used in email templates and the admin panel.
e.g. My Store
SENDGRID_API_KEYOptionalSendGrid API key for transactional emails (order confirmations, password resets, welcome emails).
SENDGRID_FROM_EMAILOptionalThe verified sender email address in your SendGrid account.
DO_SPACES_ENDPOINTOptionalDigitalOcean Spaces endpoint URL.
e.g. https://sfo3.digitaloceanspaces.com
NEXT_PUBLIC_DO_SPACES_CDNOptionalCDN endpoint for serving media files publicly. Used in Next.js image remotePatterns.
e.g. https://your-bucket.sfo3.digitaloceanspaces.com
DO_SPACES_REGIONOptionalDigitalOcean Spaces region.
e.g. sfo3
DO_SPACES_BUCKETOptionalName of your Spaces bucket.
DO_SPACES_FOLDEROptionalRoot folder within the bucket for this deployment's uploaded files. Use different values for dev vs production.
e.g. production
DO_SPACES_KEYOptionalSpaces access key ID. Generate under API β†’ Spaces Keys in your DO account.
DO_SPACES_SECRETOptionalSpaces secret access key. Shown only once at creation time.
GOOGLE_CLIENT_IDOptionalGoogle OAuth client ID for Google sign-in. Create credentials at console.cloud.google.com.
GOOGLE_CLIENT_SECRETOptionalGoogle OAuth client secret. Never expose this on the client.

Payment & Shipping Credentials

Payment processor keys (Stripe, Authorize.net, Clover, Square) and shipping provider keys (EasyPost, Shippo, ShipStation) are not configured through environment variables. They are entered directly in the admin panel under Settings β†’ Payment Settings and Settings β†’ Shipping Settings, then stored encrypted in the database using APP_ENCRYPTION_KEY. This means you can change providers without redeploying.

Security Notes