I started facing this as of yesterday. I started new chat with copying the main branch, which is also the code in production where things are working ok. I make a very very simple change in v0 and I started getting this error:
installHook.js:1 Supabase URL or Anon Key is missing. Returning null client.
Per the chat with v0 it is the v0 environment issue. I can grab the preview URL from Vercel and test there but the preview from v0 fails.
This is definitely a v0 preview environment limitation. The error shows that process.env.NEXT_PUBLIC_SUPABASE_URL and process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY are returning undefined in the browser.
In Next.js, NEXT_PUBLIC_* environment variables are replaced at build time by the bundler (Turbopack/Webpack). They’re not actually read from process.env at runtime - Next.js injects the values during the build process.
The Problem
The v0 preview was built before the environment variables were available in the system, so the build has undefined hardcoded where the env vars should be.
Why this works in production
When you deploy to Vercel, the build runs with the environment variables available, so they get properly injected into the bundle.
Solutions
- This issue only affects v0 preview - Your production deployment will work fine because
Vercelbuilds with the env vars available. - To test in v0, you can:
- Check your production/preview deployment on
Vercelinstead. - Wait for
v0to auto-restart (happens periodically but can’t be manually triggered).
- Check your production/preview deployment on
