supabaseUrl is required

The console says supabaseUrl is required? createClient got an empty URL. Set the project URL the code reads, then rebuild.

Reviewed October 16, 2026

What it means in plain English

The Supabase client refused to start. supabase-js throws supabaseUrl is required. when the URL string is empty or only spaces. A URL that is not http:// or https:// throws Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL. instead.

Supabase's JavaScript reference says both supabaseUrl and supabaseKey are required. The URL is the one supplied when you create the project. The client does not invent it.

Likely causes

  • The variable the code reads is missing in the environment that built the site, so it is undefined.
  • The code reads import.meta.env.VITE_SUPABASE_URL (Vite) or process.env.NEXT_PUBLIC_SUPABASE_URL (Next.js), and the host saved a different name.
  • Vite folded the value in at build time. Adding it later, without a new build, leaves the live bundle empty.
  • The string in the host is not the project URL. It has to be an https:// URL, not the project id by itself.

How to fix it, step by step

  1. Find the createClient call. Note the exact variable names. Do not rename them in the host to something the code does not read.
  2. Copy the project URL from the Supabase project dashboard. The initializing reference says that URL is supplied when you create the project. It looks like https://your-project-id.supabase.co.
  3. For a Lovable Cloud project hosted somewhere else, Lovable's guide says to set VITE_SUPABASE_URL and VITE_SUPABASE_PUBLISHABLE_KEY before the build. Copy those names from the project's .env if the code uses them.
  4. Put the same names on the host, for the Production environment, then redeploy. On Vite, a name without the VITE_ prefix stays off the browser bundle. See Vite env var missing the VITE_ prefix.
  5. Use the publishable key as supabaseKey in browser code. Do not put a secret key in a VITE_ or NEXT_PUBLIC_ variable.

How to check it worked

  • Reload the live site. The console no longer says supabaseUrl is required.
  • A request from the page goes to https://your-project-id.supabase.co, not to an empty host.

Sources

More Supabase keys and config fixes

More Environment variables fixes

Keep going on your own.

The guides stay free. A deep leak report is $15. Fix packs are $24, or $49 for all three. There is no done-for-you repair.

See products