Lovable app 404 on Vercel or Netlify after export: find your stack, then fix it
You connected your Lovable project to GitHub, imported the repository into Vercel or Netlify, and the build went green. Then you opened the live URL and got a 404: NOT_FOUND page. Or the home page loads, but refreshing /dashboard gives a 404. You add the vercel.json rewrite every forum answer suggests, redeploy, and nothing changes.
The reason is usually that there are now two kinds of Lovable app, and they need opposite fixes. Lovable's own docs say projects created from May 13, 2026 are built with TanStack Start, which renders pages on a server, while older projects are plain React + Vite single-page apps that build to static files. The rewrite that fixes an old app does nothing for a new one, because a TanStack Start app needs a host that runs its server code. This guide shows how to tell which one you have and fixes each one, step by step. If your problem is a blank page rather than a 404, start with Lovable app works in preview but breaks after deploy.
Step 0: find out which stack your project uses (1 minute)
Open package.json in your GitHub repository (or in Lovable's Code tab). Lovable's docs give this test:
| What you see in package.json | Your stack | What the host has to do | Go to |
|---|---|---|---|
@tanstack/react-start is listed under dependencies | TanStack Start (projects created from May 13, 2026) | Run the server part: server-side rendering, server functions and API routes | 2 and 3 |
No @tanstack/react-start; react-router-dom and vite instead | Older React + Vite single-page app | Serve the static dist/ folder, with a fallback to index.html for every route | 1 |
If you're not sure, ask Lovable in the project chat: "Which stack does this project use, older React + Vite or TanStack Start?" That question comes straight from Lovable's hosting guide.
Read the 404 before changing anything
Where the 404 comes from narrows the cause down quickly:
| What you see | Likely cause | Go to |
|---|---|---|
Older app: home page works, refreshing or opening /dashboard directly shows the host's 404 page | No fallback to index.html for client-side routes | 1 |
TanStack Start app: build is green, but every URL, including /, shows Vercel's 404: NOT_FOUND | Vercel got static files (or nothing it recognizes) instead of a server build | 2 |
| TanStack Start app: it works on one host but not another | The build is pinned to a different platform's preset | 3 |
| The build fails on the host but works on your computer or in Lovable | Lockfile, package manager or Node version mismatch | 4 |
| Pages load but data, login or server functions fail | Missing environment variables or redirect URLs, not routing | 5 |
Also open the deployment's build log and function logs on your host for the same minute. On Vercel, a 404 page with an ID like NOT_FOUND comes from the platform itself, which means your app never got the request.
1. Older React + Vite app: add the index.html fallback
Signature: package.json has no @tanstack/react-start, the home page loads, and any other route returns 404 when opened directly or refreshed.
An older Lovable app has one real HTML file, index.html. React Router decides what to show in the browser. When someone opens /dashboard directly, the host looks for a file called dashboard, finds none, and returns 404. Lovable's docs say to configure a fallback so every route serves /index.html, and the method depends on the host.
Vercel: add vercel.json at the repository root:
{ "rewrites": [{ "source": "/(.*)", "destination": "/index.html" }] }
Netlify: Lovable's docs point to a _redirects file. Put it in public/ so Vite copies it into dist/, with this rule:
/* /index.html 200
Cloudflare Pages: if your build has no top-level 404.html, Pages treats the project as a single-page app and serves index.html for unknown routes. A 404.html left in public/ turns that off.
Apache or shared hosting: Lovable's docs give this .htaccess:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
Build settings for older apps, from Lovable's docs: build command npm run build, output directory dist, Node.js 22. For a storage bucket behind a CDN, Lovable warns not to rely on the bucket's error-page setting, because it answers with a 404 status code. Configure the CDN to return index.html with a 200 instead.
2. TanStack Start app: give the host a server build
Signature: package.json lists @tanstack/react-start, the deploy succeeds, and the live site is a 404 everywhere, or SSR pages and server functions fail while the same project works on Lovable's hosting.
A TanStack Start app is closer to Next.js than to a static site. Lovable's docs are direct: a host that receives only the static files does not run server-side rendering, server functions or API routes. Lovable's build config, the @lovable.dev/vite-tanstack-config package, uses Nitro to package the server output for whichever platform it builds on. Nitro calls each target a preset. Inside Lovable the preset is fixed; outside Lovable, the build picks the preset for the platform it detects, or the one you name.
Don't add the SPA rewrite
Lovable's docs say not to use the index.html fallback from the older examples for a TanStack Start app, because the server handles routing. If you already added a catch-all vercel.json rewrite or a _redirects file while trying to fix the 404, remove it.
Update the Lovable build config and check Nitro is installed
Vercel's Lovable docs say zero-configuration detection needs @lovable.dev/vite-tanstack-config at version ^2.6.2 or higher. Lovable's docs add that package.json must list nitro: without it, the build doesn't package the app for a hosting platform, and older build configurations can skip Nitro outside Lovable or write to a different output folder.
npm install "@lovable.dev/vite-tanstack-config@^2.6.2" nitro
git add package.json package-lock.json
git commit -m "Update Lovable build config for external hosting"
git push
Lovable's Git sync works both ways, so this commit also reaches the Lovable editor. Check that the Lovable preview still works after the change (see section 6).
Host settings
| Host | Build command | Output / publish directory | Node.js |
|---|---|---|---|
| Vercel | npm run build | Leave empty: Vercel needs no output directory | 22 |
| Netlify | npm run build | dist | 22 |
| Cloudflare Pages | npm run build | dist | 22 |
These values come from Lovable's hosting guide. On Vercel, also clear any Output Directory or Build Command override left over from an earlier attempt, and make sure the project isn't set up as a plain static Vite site. Then redeploy. If you changed settings rather than code, choose Redeploy on the latest deployment so the new settings apply.
Hosts that can't run it
GitHub Pages, an S3 or Cloud Storage bucket behind a CDN, Netlify Drop and plain shared hosting only serve files. Lovable's docs say a TanStack Start app doesn't run from object storage or a CDN alone. Use a platform Nitro detects, a container, or your own server (section 3).
3. The build targets the wrong platform
Signature: the same repository works on one host and 404s on another, or you followed a forum fix that hard-codes a preset.
Nitro builds a different output for every platform, so a preset pinned to one host produces something the next host can't serve. Look for:
- A
NITRO_PRESETenvironment variable in your host's settings or your CI. - A
nitro: { preset: "..." }option, or a hand-addednitro()plugin with a preset, invite.config.ts.
On Vercel, Netlify and Cloudflare Pages, Lovable's docs say a build from your repository picks the matching preset with no configuration, so with a current build config you can usually delete the override. Vercel's docs likewise say no manual build configuration is needed for Lovable projects. In some projects the generated vite.config.ts carries a comment that Nitro builds with Cloudflare as the default target, which explains why an old config can keep producing a Cloudflare build on Vercel.
For a VPS, a container or any host Nitro doesn't detect, Lovable documents the Node.js server preset:
NITRO_PRESET=node-server npm run build
node .output/server/index.mjs
The server listens on port 3000 (set PORT and HOST to change it). Put it behind your reverse proxy for HTTPS, and don't add the Nginx try_files fallback from the older examples, because the server does the routing.
4. Builds on your computer, fails on the host
Signature: the deploy itself is red, so you never even get to the 404.
- Lockfile mismatch. Lovable's docs note that if your repository only has
bun.lock, you should either install with Bun on the host or runnpm installlocally and commit the generatedpackage-lock.json. Keep one package manager and one lockfile, and make the host's install command match it. Cannot find module @rollup/rollup-linux-x64-gnu. Rollup's own error message points to an npm bug with optional dependencies (npm/cli#4828) and says to delete bothpackage-lock.jsonandnode_modules, then runnpm iagain. Commit the regenerated lockfile.- Node version. Lovable's build settings use Node.js 22. Set the same version in your host's project settings.
- File name casing and missing files. These are the same build breakers as in any Vite or Next.js project. See Vercel build failed: "Module not found".
5. Not a 404: pages load, but data, login or server functions fail
Once routing works, the next break is usually configuration that lived only inside Lovable:
- Browser variables. A project on Lovable's built-in backend needs
VITE_SUPABASE_URLandVITE_SUPABASE_PUBLISHABLE_KEY(copy the exact names from the repository's.envfile; some older projects useVITE_SUPABASE_ANON_KEY). Both stacks embed browser values at build time, so set them before the build and redeploy after changing them. - Server variables (TanStack Start only). Server code reads
SUPABASE_URLandSUPABASE_PUBLISHABLE_KEY, plus any secrets your server functions use. Lovable's docs point out that those secrets aren't in the repository, so you add them on the host yourself. Keep secrets without theVITE_prefix so they never reach the browser. - Sign-in redirect URLs. Add the new domain to your authentication provider's allowed redirect URLs, or login bounces back to the old address. Details in Supabase auth broken in a Bolt or Lovable app.
- Features that still run through Lovable. Lovable's docs say app connectors and AI features keep running through Lovable while the project uses the built-in backend. Moving the frontend doesn't change that.
For the full variable checklist across hosts, see Environment variables missing in production.
6. Keep Lovable and your host in step
- Two sites, two buttons. Lovable's Publish button publishes to Lovable hosting only. Your
lovable.appaddress keeps serving the version you last published there, while Vercel or Netlify deploys whatever is pushed to the branch it watches. Comparing the two is a quick way to see whether a bug is in the code or in the host. - Edits flow both ways. With Git sync connected, a change you push to GitHub (like a
vite.config.tsedit) also lands in the Lovable project. Change one thing at a time and check the Lovable preview after each push. - Use a temporary URL first. Lovable recommends deploying to the new host's temporary URL and verifying it before you move your custom domain.
A check before you switch your domain
Lovable's hosting guide lists these checks on the new host, against the app running on Lovable:
- Open a nested route directly and refresh it. A 404 means a missing
index.htmlfallback (older apps) or a host that isn't running the server part (TanStack Start). - Sign in and sign out. A redirect error means the new URL is missing from the allowed redirect URLs.
- Run the reads, writes and uploads your app depends on.
- For TanStack Start, open a server-rendered page and trigger a server function, not only the browser interface.
How to prompt Lovable so it doesn't make things worse
Asking "fix the 404 on Vercel" invites the AI to bolt a static-site rewrite onto a server app, or to rewrite your routing. Give it the stack, the evidence and a narrow job instead:
This project deploys from GitHub to [Vercel/Netlify]. The build succeeds but [every route / only refreshed routes] return 404.
1. Tell me which stack this project uses: TanStack Start or older React + Vite.
2. If TanStack Start: check that @lovable.dev/vite-tanstack-config is ^2.6.2 or newer and that nitro is in package.json.
List any NITRO_PRESET or nitro preset override and any SPA rewrite file (vercel.json, _redirects). Don't add a rewrite.
3. If React + Vite: add only the index.html fallback for [host].
4. List every environment variable the browser and the server code read.
Change only build and hosting config. Don't touch routes, components, auth or database code.
If the answer is a host setting (output directory, Node version, environment variables), no code change will help. Make the change on the host and redeploy.
FAQ
Why does my Lovable app show 404: NOT_FOUND on Vercel when the build succeeded?
Projects created in Lovable from May 13, 2026 use TanStack Start and need a host that runs their server code. If Vercel gets only static files, or an old build config that doesn't produce a Vercel server build, nothing answers the request. Update @lovable.dev/vite-tanstack-config to ^2.6.2 or newer, make sure nitro is in package.json, clear any output directory override and redeploy.
Should I add a vercel.json rewrite to /index.html?
Only for an older React + Vite Lovable app, where it fixes 404s on refreshed routes. Lovable's docs say not to use that fallback for a TanStack Start app, because the server handles routing. Check package.json first: if it lists @tanstack/react-start, remove the rewrite instead.
How do I know if my Lovable project is TanStack Start or React + Vite?
Open package.json in the Code tab or your GitHub repository. A TanStack Start project lists @tanstack/react-start under its dependencies; an older React + Vite project does not. You can also ask Lovable in the project chat which stack the project uses.
Which output directory should I set for a Lovable app?
For an older React + Vite app, dist. For a TanStack Start app, Lovable's docs say dist on Netlify and Cloudflare Pages, and no output directory setting on Vercel. Use npm run build and Node.js 22 in both cases.
Can I host a new Lovable app on GitHub Pages or shared hosting?
Not a TanStack Start app. Those hosts only serve files, and Lovable's docs say a TanStack Start app doesn't run from static hosting or a CDN alone. Use a platform Nitro detects, such as Vercel, Netlify or Cloudflare Pages, or build with NITRO_PRESET=node-server and run node .output/server/index.mjs on a server or container.