Back to Spree

Environment Variables

docs/developer/storefront/nextjs/environment-variables.mdx

5.6.04.5 KB
Original Source

Configuration lives in .env.local (copy .env.example to start). Variables without a NEXT_PUBLIC_ prefix are server-side only and never reach the browser; NEXT_PUBLIC_ variables are inlined into the client bundle at build time, so only put non-secret values there.

Required

VariableDescription
SPREE_API_URLYour Spree API endpoint (e.g. http://localhost:3000 in dev, https://api.mystore.com in production)
SPREE_PUBLISHABLE_KEYPublishable API key from your Spree admin
<Note> In a Docker build these two are also required at **build time** — the storefront prerenders pages against the Spree API. See [Deployment](/developer/storefront/nextjs/deployment). </Note>

Store defaults

Used by the middleware for initial redirects before API data loads, and as build-time fallbacks for sitemap/SEO generation.

VariableDescriptionDefault
NEXT_PUBLIC_DEFAULT_COUNTRYDefault country ISO code — should match your store's default_country_isous
NEXT_PUBLIC_DEFAULT_LOCALEDefault locale code — should match your store's default_localeen
NEXT_PUBLIC_SITE_URLPublic site URL, used for sitemap and robots.txt generation (e.g. https://mystore.com)(required for sitemap)
NEXT_PUBLIC_STORE_NAMEStore name used in metadata fallbacksSpree Store
NEXT_PUBLIC_STORE_DESCRIPTIONStore description used in metadata fallbacks(sample text)

SEO & social

Optional overrides for site metadata and the Organization JSON-LD. When unset, values fall back to store settings from the Spree API.

VariableDescription
STORE_SEO_TITLEDefault <title>
STORE_META_DESCRIPTIONDefault meta description
STORE_META_KEYWORDSDefault meta keywords
STORE_TWITTERTwitter/X handle or URL
STORE_FACEBOOKFacebook page URL
STORE_INSTAGRAMInstagram URL
STORE_LOGO_URLLogo URL for Organization JSON-LD
STORE_SUPPORT_EMAILCustomer support email

Wholesale B2B portal

The wholesale portal is an opt-in addon, off by default.

VariableDescriptionDefault
SPREE_WHOLESALE_CHANNELEnable switch — the code of a gated Spree channel to bind the /wholesale surface to. Unset means DTC-only: every wholesale entry point is hidden and the routes 404(disabled)
SPREE_WHOLESALE_PUBLISHABLE_KEYChannel-scoped publishable key for the wholesale surface. Optional — the channel header selects the channel, so this falls back to SPREE_PUBLISHABLE_KEY(falls back to SPREE_PUBLISHABLE_KEY)

Transactional emails

See the Transactional Emails guide for the full setup.

VariableDescriptionDefault
SPREE_WEBHOOK_SECRETWebhook endpoint secret key that signs incoming Spree webhooks(disabled)
RESEND_API_KEYResend API key for sending emails in production(dev: writes to disk)
EMAIL_FROM"From" address for transactional emails (e.g. Store <[email protected]>)[email protected]

Payments

Publishable keys for client-side payment SDKs, read when the matching gateway is enabled. Set the key for whichever provider(s) you use.

VariableDescription
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEYStripe publishable key (pk_…)

Analytics

VariableDescriptionDefault
GTM_IDGoogle Tag Manager container ID (e.g. GTM-XXXXXXX). Leave empty to disable(disabled)

Error tracking (Sentry)

VariableDescriptionDefault
SENTRY_DSNSentry DSN — set to enable error tracking (e.g. https://[email protected]/0)(disabled)
SENTRY_ORGSentry organization slug (for source map uploads)(none)
SENTRY_PROJECTSentry project slug (for source map uploads)(none)
SENTRY_AUTH_TOKENSentry auth token (for source map uploads in CI)(none)
SENTRY_SEND_DEFAULT_PIISend PII (IP addresses, cookies, user data) to Sentry server-sidefalse
NEXT_PUBLIC_SENTRY_SEND_DEFAULT_PIISend PII to Sentry client-sidefalse
<Warning> PII collection is disabled by default. Only set the `SENTRY_SEND_DEFAULT_PII` variables to `true` if you have appropriate user consent or a privacy policy covering this data. </Warning>