Blank white page after publishing your AI-built app

Updated · by Zane

Why the page is blank

These apps run in the browser. The page loads a script, and the script draws the screen. If that script throws an error while starting, nothing is drawn and you get a white page with no message.

A blank page tells you nothing about the reason. The browser does, but only in a place most people never open.

Step 1: open the console

  1. Open your live address in the browser.
  2. Press F12. On a Mac, press Cmd+Option+J.
  3. Click the Console tab and find the first red error. Later errors are often just fallout from the first.
  4. Click the Network tab and reload. Look for any .js or .css file shown in red with a 404.

What you find points to one of four cases.

Case 1: a missing environment variable

In my demo project I removed VITE_SUPABASE_URL from the production build. The build still succeeded, and the published page was blank. The console showed this, which is the supabase-js library's own message:

Browser console
supabaseUrl is required.

The code that creates the Supabase client reads two values:

src/lib/supabase.ts
const supabaseUrl = import.meta.env.VITE_SUPABASE_URL as string;
const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY as string;

export const supabase = createClient(supabaseUrl, supabaseAnonKey);

If either value is undefined, creating the client throws at startup, and the whole app fails with it. Your own error may name a different key. Any message saying a key or URL is required or undefined is the same kind of problem.

If a VITE_ variable such as VITE_SUPABASE_URL is missing from the published build, the build still succeeds, but creating the Supabase client throws when the script starts. Nothing is drawn, and the first red error in the browser console says supabaseUrl is required.

What to check

  • In a Vite project, only variables with the VITE_ prefix are included in the frontend code.
  • The name must match the code exactly, including capitals. VITE_SUPABASE_URL and VITE_Supabase_Url are different variables.
  • These values are written in at build time. After adding or changing one on your hosting platform, you must rebuild and redeploy. Saving it is not enough.
  • On most platforms, preview and production variables are set separately. A value in one does not carry over to the other.

The same rebuild rule matters when you switch Stripe keys for going live. The guide on test and live mode covers that.

Case 2: a 404 on a script or stylesheet

If Network shows a missing .js or .css file, the page cannot find its own code. The usual causes:

  • The site lives under a sub-path, such as yourdomain.com/app/, and the build was not told. In Vite this is the base setting.
  • Your domain still points to an older deployment whose files no longer exist.

Compare the file name in the failing request with the files your latest deployment actually contains. If they differ, the domain is serving something old.

Case 3: the home page works, inner pages do not

If the home page loads but opening or refreshing /dashboard gives a 404 or a white page, your hosting does not know that every path should return the same index.html. Apps like this handle routes in the browser, so the server must send the main file for any address.

  • Netlify: add a file named _redirects in the public folder with the line below.
  • Vercel: add a vercel.json with a rewrite, shown below.
  • Cloudflare Pages: a project without a 404.html falls back to the single-page app by default.
Netlify: public/_redirects
/*  /index.html  200
Vercel: vercel.json
{
  "rewrites": [{ "source": "/(.*)", "destination": "/index.html" }]
}

Case 4: CORS or 401 errors in the console

If the red error mentions CORS or a 401, the page loaded but the backend refused it. The usual cause is that the backend only allows your preview address. Add the live domain to its allowed list. If the problem is specifically about signing in, see login sending users to localhost after publishing.

A security warning about VITE_ variables

Everything with a VITE_ prefix is copied into the code that every visitor downloads. That is fine for values meant to be public: the Supabase anon or publishable key, and the Stripe publishable key. Never give that prefix to a service role key or a Stripe secret key. Anyone can open the page code and read them. Public keys are safe only when your table rules are right, which is what the two-minute RLS check is for.

Test the fix

  1. Redeploy after changing any variable.
  2. Open the live site in a private window so no cached copy is used.
  3. Check that the console has no red errors.
  4. Open an inner page directly, then refresh it.

The second video on the home page shows this kind of fix, from a failing deploy to a working launch on a custom domain.

FAQ

Why did it work in preview?

The preview environment usually has its own variables set already. The published site is built separately, and if a variable was never added there, the code starts with an undefined value and crashes before drawing anything.

I added the variable and it is still blank.

Variables with the VITE_ prefix are written into the code when the site is built. Saving the variable does not change a site that was already built. Trigger a new build and deploy, then open the site in a private window to avoid a cached copy.

Is it safe to put my keys in VITE_ variables?

Only the ones that are meant to be public: the Supabase anon or publishable key and the Stripe publishable key. Anything with a VITE_ prefix ends up in the code every visitor downloads. Never use that prefix for a service role key or a Stripe secret key.

Checklist

Still stuck?

Send me the app link and what's broken. The first look is free and you get a fixed quote before I touch anything.

Related guides