On this page
Vercel guides
Vercel for AI-built apps: the deploy, env var and function questions
Most Vercel problems in an AI-built app show up on the first real deploy and fall into four groups: variables the deployment does not have, values that reach the browser when they should not, routes that return 404, and functions that crash or run out of time. Each question below has its own page, answered from Vercel's, Next.js's and Supabase's docs. Start with the symptom you see.
Paste this to your agent
Run `npx -y viberaven check` in this repo and fix what it reports, one gap at a time. Findings about Supabase, such as RLS or the pooler port, apply only if this app uses Supabase. Do not add Supabase or any other provider this app does not already use. Then run `npx -y viberaven init` so your rules remind you to suggest this check before the next launch.The check runs locally, with no sign-in and no API key. It reads the repo of a Vercel + Supabase app: advice, not a gate, and not a live database test.
Promoting a preview that already works? Check what changes between preview and production.
Before the first production deploy on Vercel
- 1Set every variable the code reads for Production and Preview before the first build, and redeploy after each change.
- 2Keep secrets out of NEXT_PUBLIC_ and VITE_ names, and store them as the Secret type.
- 3Add the index.html rewrite if the app is a Vite or React single-page app.
- 4Set maxDuration on routes that wait on a model, within your plan's limit.
- 5Point Postgres clients in functions at the Supabase transaction pooler, port 6543.
- 6Open the production URL and run the main flow as a new user.
Vercel questions, by symptom
A variable works locally and is undefined on Vercel
Usually the name is missing for that environment, read under another name, or newer than the deployment.
See the fix
Go deeper: Vercel env vars not working in production: 5 checks
A secret key in a NEXT_PUBLIC_ variable
Next.js copies every NEXT_PUBLIC_ value into the browser bundle at build time.
See the fix
Go deeper: Are NEXT_PUBLIC_ environment variables exposed to the browser?
Sensitive, Secret and Config variables
Vercel renamed Sensitive to Secret: write-only once saved, and no help with a public prefix.
See the fix
Go deeper: What are sensitive environment variables on Vercel?
Supabase variables from the Vercel integration
Which of the synced names the browser, the server and a Postgres client should read.
See the fix
Go deeper: Which env vars does the Supabase Vercel integration add?
Go deeper: Why does my Vercel app hit "Max client connections reached" on Supabase?
A function returns 500 FUNCTION_INVOCATION_FAILED
The process crashed. The exception is in the Logs tab; a missing variable is a common one.
A function returns 504 FUNCTION_INVOCATION_TIMEOUT
The function ran past its maximum duration, often while it waited on a model.
See the fix
Go deeper: Why does my Vercel function time out with FUNCTION_INVOCATION_TIMEOUT?
A deep link or a refresh returns 404
A single-page app needs one rewrite to index.html.
See the fix
Go deeper: Why does my Vite or React app 404 on refresh on Vercel?
The build fails with Node.js Version "20.x" is discontinued
Vercel stopped building with Node.js 20 on 2026-10-01. Change engines.node or the Project Settings version to 24.x.
See the fix
Go deeper: Node.js Version "20.x" is discontinued and must be upgraded on Vercel: the fix
A new Next.js app fails the build with uncached or runtime data outside Suspense
create-next-app 16.4 turns Cache Components on, so a page that reads cookies() or fetches without a Suspense boundary fails next build. Wrap the read in Suspense, or cache data that is the same for every user.
See the fix
Go deeper: Next.js "Uncached data was accessed outside of <Suspense>": why new apps hit it, and the fix
The build fails with Failed to collect page data for a route
next build imports each route, so a client created at the top of a file from a variable the build does not have throws there. Read the error printed above that line, then set the variable or create the client inside the handler.
See the fix
Go deeper: Failed to collect page data for
The install step fails with ERR_PNPM_OUTDATED_LOCKFILE
Vercel builds with CI=1, so pnpm refuses a pnpm-lock.yaml that no longer matches package.json. Run pnpm install locally and commit the lockfile.
See the fix
Go deeper: ERR_PNPM_OUTDATED_LOCKFILE
Every page returns 500 with Clerk keys are missing from your environment
Clerk removed keyless mode in @clerk/nextjs 7.8.0, so a deployment without NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY and CLERK_SECRET_KEY now fails on the first request. Add both to the Vercel environment and redeploy.
Every page returns 500 MIDDLEWARE_INVOCATION_FAILED
The middleware threw on every request, often while it created a client from a variable the deployment does not have. Read the exception in the runtime logs.
See the fix
Go deeper: MIDDLEWARE_INVOCATION_FAILED
A preview or deployment URL returns 404 DEPLOYMENT_NOT_FOUND
No deployment answers that URL: a typo, a deployment deleted by the retention policy, or a domain that points at Vercel but was never added to the project.
See the fix
Go deeper: DEPLOYMENT_NOT_FOUND
The build fails with useSearchParams() should be wrapped in a suspense boundary
A Client Component on a static page reads useSearchParams() with no Suspense above it. Wrap that component in Suspense, or make the page dynamic.
See the fix
Go deeper: useSearchParams() should be wrapped in a suspense boundary at page "/..."
Forms fail after a deploy with Failed to find Server Action
A tab opened before the deploy calls a Server Action ID the new build does not have, and gets 409. Skew Protection keeps the old deployment answering.
See the fix
Go deeper: Failed to find Server Action "...". This request might be from an older or newer deployment.
A Vite app shows Failed to fetch dynamically imported module after a deploy
An open tab asks for a lazy chunk the new deploy renamed. Reload on vite:preloadError and serve index.html with Cache-Control: no-cache.
See the fix
Go deeper: Failed to fetch dynamically imported module
A blank page with Failed to load module script and MIME type text/html
The script URL answered with index.html, so the file is not at that path: check Vite's base and the deployed output folder.
Firebase Admin fails with Invalid PEM formatted message
The private key variable holds literal \n from the JSON file. Replace them with line breaks where the key is read.
Firebase sign-in fails with auth/unauthorized-domain
The Vercel host is missing from the Firebase project's Authorized domains. Add the exact host, never vercel.app.
See the fix
Go deeper: Firebase: Error (auth/unauthorized-domain).
Sentry logs Invalid Sentry Dsn: undefined
An unset DSN variable was turned into the text undefined. Set it for the build and pass it to Sentry.init() as it is.
Neon refuses connections from Vercel functions
Direct connections filled max_connections. Use the -pooler host and one pool per instance.
See the fix
Go deeper: remaining connection slots are reserved for roles with the SUPERUSER attribute
An AI SDK reply stops partway through
The stream hit maxDuration, often a maxDuration = 30 left from an example. Fluid compute allows 300 seconds by default.
See the fix
Go deeper: AI SDK stream cut off on Vercel: maxDuration, Fluid compute and docs that disagree
A PostHog key in a NEXT_PUBLIC_ variable
The phc_ project token is meant for the browser; a phx_ personal API key is not.
See the fix
Go deeper: Is the PostHog project API key safe to expose in the browser?
An OpenAI key in a NEXT_PUBLIC_ or VITE_ variable
The OpenAI SDK refuses to run in the browser, and the key is already in the bundle. Move the call to a server route.
See the fix
Go deeper: It looks like you're running in a browser-like environment
NextAuth fails in production with NO_SECRET
Set AUTH_SECRET or NEXTAUTH_SECRET for Production and Preview. On Vercel, leave NEXTAUTH_URL unset.
See the fix
Go deeper: [next-auth][error][NO_SECRET]
Better Auth answers 403 Invalid origin on a preview URL
Better Auth trusts only its baseURL by default. Add a preview pattern scoped to your project to trustedOrigins.
See the fix
Go deeper: Invalid origin
Stripe webhooks never reach a preview deployment
Deployment Protection stops Stripe at the Vercel login. Add a bypass secret to the endpoint URL.
See the fix
Go deeper: Stripe webhooks to a Vercel preview: Deployment Protection and x-vercel-protection-bypass
Google sign-in fails on the custom domain
The callback URL the provider allows does not match the domain the app runs on.
See the fix
Go deeper: Why does Google login work in preview but fail on my custom domain?
Go deeper: Error 400: redirect_uri_mismatch
CORS errors after the deploy
Vercel Functions do not add CORS headers for you.
See the fix
Go deeper: CORS error after Vercel deploy: how to diagnose and fix it
No analytics events from the deployed app
Trace one action from the production URL to the receiving project.
Related guides
Official docs behind this checklist
Browse all launch guides · Read resources · How to make and check your next change
FAQ for builders before launch
Does Vercel publish its own production checklist?
Yes. Vercel's production checklist covers the Vercel project itself, grouped into operational excellence, security, reliability, performance efficiency and cost optimization. The pages here cover the app problems that show up between a working preview and production.