Vercel can’t read Supabase environment variables

Vercel can’t read Supabase environment variables in two separate Next.js projects (despite being configured in Vercel)

I’m running into an issue where Vercel doesn’t see Supabase environment variables at runtime in two separate Next.js projects. In both cases, variables are configured in Vercel Project Settings → Environment Variables and redeploys were done multiple times, but the app behaves as if variables are missing.

Symptom

  • The app shows “Supabase environment variables required”

  • It behaves as if NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY are undefined on the client, and SUPABASE_SERVICE_ROLE_KEY is missing on the server.

Projects

  1. Project A: Next.js SaaS Starter (custom skeleton), integrated with Supabase

  2. Next.js 14 with App Router

  3. Hosted on Vercel

  4. Supabase project in EU (eu-central-1)

  5. Vercel Project id: prj_U29lC6Ar1hWXuXOS2ky7ty4tsbx2

  6. Project B: Next.js Supabase Starter (official template)

  7. Created following the official Supabase ↔ Vercel integration guide: https://supabase.com/partners/integrations/vercel

  8. Hosted on Vercel

  9. Separate, new Supabase project (EU)

  10. Vercel Project id: prj_dKRTCXVwH3ZRLEMxKnOfhNVPRDeQ

Environment variables set in Vercel (Production + Preview)

  • NEXT_PUBLIC_SUPABASE_URL=https://<project-ref>.supabase.co

  • NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOi... (anon key)

  • SUPABASE_SERVICE_ROLE_KEY=eyJhbGciOi... (service role)

  • Additionally, DB connection strings (POSTGRES_URL / PRISMA_URL / NON_POOLING), but the main issue is with the Supabase keys.

  • All values are visible and non-empty in Vercel UI.

What I’ve already checked

  • Redeploy after each env change.

  • Variables exist for the correct Environments (Production and Preview), not only Development.

  • Client-side vars use the NEXT_PUBLIC_ prefix.

  • I’m not relying on repo .env files for Vercel builds; I know Vercel uses its own Project Settings envs.

  • In Next.js: server code reads process.env.*, client reads NEXT_PUBLIC_*.

  • Verified via vercel env ls / vercel env pull locally that variables exist on Vercel.

  • These are not monorepos; the project root directory is correct (no wrong “Root Directory” pointing elsewhere).

  • Tried full redeploys (not only “redeploy with cache”).

  • In one project I had a duplicate definition of NEXT_PUBLIC_SUPABASE_ANON_KEY in files — removed — no change on Vercel behavior.

Hypotheses

  • Edge runtime/middleware: Is there any additional requirement for exposing env vars to Edge runtime on Vercel? Do Supabase keys need special handling for Edge?

  • Scope collision: Could there be a collision between Team-level and Project-level envs? What’s the best way to confirm precedence?

  • Build vs runtime: Is there a difference in availability between build-time and runtime (SSR/Edge) in Next.js 14 that I need to account for?

  • Official starter specifics: Does the Supabase Next.js Starter include an extra guard/check that expects variables in a different place or format on Vercel?

Questions

  • Has anyone seen Vercel fail to provide env vars to runtime (SSR/Edge) even when they’re present in Project Settings?

  • For Edge functions/middleware, do I need to explicitly mark env vars for availability?

  • What’s a recommended minimal diagnostic to confirm env availability in runtime without leaking secrets? (e.g., boolean flags or length checks)

  • Any known Next.js 14 (App Router) specifics that affect env availability on Vercel?

  • Does the official Next.js Supabase Starter require any additional Vercel config for envs beyond standard setup?

Versions

  • Next.js: 14.x (App Router)

  • Node: Vercel default

  • Vercel: latest dashboard

  • Supabase CLI: 2.39.x (local), EU region projects

  • Region: eu-central-1 for Supabase

Reproduction (short)

  1. Create a Next.js App Router app and deploy to Vercel.

  2. In Vercel → Project Settings → Environment Variables set:

    • NEXT_PUBLIC_SUPABASE_URL

    • NEXT_PUBLIC_SUPABASE_ANON_KEY

    • SUPABASE_SERVICE_ROLE_KEY

  3. Deploy. App shows “Supabase environment variables required” as if envs are missing.

Attachments