supacommerce

Environment Variables

A complete reference of all environment variables used by supacommerce.

Environment Variables

supacommerce uses two categories of environment variables — local .env variables for your app and Drizzle, and Supabase edge function secrets for the server-side functions.

The CLI copies a .env.example file into your project. Rename it to .env and fill in your values.

Local .env

These live in your project's .env file and are used by Drizzle and your frontend apps.

Base

VariableRequiredDescription
DATABASE_URLYesPostgres connection string for Drizzle migrations. Found in Supabase under Settings → Database → Connection string → URI.

Dashboard app

VariableRequiredDescription
VITE_SUPABASE_URLYesYour Supabase project URL
VITE_SUPABASE_ANON_KEYYesYour Supabase anon key — safe to expose client-side
VITE_SUPABASE_SERVICE_ROLE_KEYSeed script onlyService role key — bypasses RLS. Used only by pnpm seed:admin. Never expose client-side.
VITE_ADMIN_EMAILSeed script onlyEmail for the first admin user
VITE_ADMIN_PASSWORDSeed script onlyPassword for the first admin user
VITE_ADMIN_FIRST_NAMESeed script onlyFirst name for the first admin user
VITE_ADMIN_LAST_NAMESeed script onlyLast name for the first admin user

Storefront app

The storefront uses the same two vars as the dashboard:

VariableRequiredDescription
VITE_SUPABASE_URLYesSame value as dashboard
VITE_SUPABASE_ANON_KEYYesSame value as dashboard

Supabase edge function secrets

These are set via the Supabase CLI and are available to all edge functions as Deno.env.get("KEY").

supabase secrets set \
  RESEND_API_KEY=re_... \
  RESEND_FROM="Your Store <orders@yourdomain.com>" \
  EMAIL_FROM="orders@yourdomain.com" \
  DASHBOARD_URL="https://your-dashboard-url.com" \
  ENVIRONMENT="development"
VariableRequiredUsed byDescription
RESEND_API_KEYYesorder-confirmed, admin-send-inviteYour Resend API key for sending emails
RESEND_FROMYesadmin-send-inviteFrom address for invitation emails, e.g. Your Store <orders@yourdomain.com>
EMAIL_FROMYesorder-confirmedFrom address for order confirmation emails
DASHBOARD_URLYesadmin-send-inviteURL of your admin dashboard — used to build the accept invitation link
ENVIRONMENTYespayment-webhookSet to development to allow the payment webhook to run without signature verification. Remove or change this when you implement signature verification in production.

Auto-injected by Supabase

These are automatically available in all edge functions — you do not set them manually:

VariableDescription
SUPABASE_URLYour Supabase project URL
SUPABASE_SERVICE_ROLE_KEYService role key — bypasses RLS
SUPABASE_ANON_KEYAnon key

Payment provider secrets

When you wire in your payment provider in supabase/functions/cart-checkout/index.ts and supabase/functions/payment-webhook/index.ts, you'll need to add provider-specific secrets. Using Stripe as an example:

supabase secrets set \
  STRIPE_SECRET_KEY=sk_live_... \
  STRIPE_WEBHOOK_SECRET=whsec_...
VariableDescription
STRIPE_SECRET_KEYStripe secret key for creating payment intents
STRIPE_WEBHOOK_SECRETStripe webhook signing secret for verifying webhook events

On this page