Vercel 404: NOT_FOUND when refreshing a page or opening a direct link
On this page
Short answer
If your app is a Vite single-page app, Vercel only has index.html and asset files, so a direct request for /dashboard finds no file and returns 404. Vercel's Vite guide says deep linking "won't work out of the box" for a SPA. Add the vercel.json rewrite below, commit, and redeploy.
Deploy Without Errors Pack
Environment variables on Vercel, Netlify and Replit, SPA refresh rewrites, npm peer dependency errors and domain setup.
Secure checkout by Stripe
One-time payment through Stripe. Priced in USD. Local taxes such as UK VAT may be added at checkout.
The exact error you'll see
Vercel's error page in the browser, with HTTP status 404:
NOT_FOUND
Source: https:/
The home page loads and in-app links work, but refreshing an inner page or opening a shared link shows this error.
Applies to
- Vite apps configured as a single-page app and deployed to Vercel, including apps exported from Lovable or Bolt
- Client-side routers such as React Router in browser-only mode
- The
vercel.jsonfile at the project root and itsrewritesproperty
Why it happens
- No server-side route for each page. In a SPA, the browser draws each page from
index.html. Vercel's Vite guide: if the app is "configured to deploy as a Single Page Application (SPA), deep linking won't work out of the box." - Missing rewrite. Without a rewrite, Vercel looks for a file at
/dashboard, finds none, and returnsNOT_FOUND, which Vercel defines as "when a requested resource could not be found."
How to fix it, step by step
- In the project root (next to
package.json), create or editvercel.jsonwith Vercel's SPA rewrite from its Vite guide:
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"rewrites": [
{
"source": "/(.*)",
"destination": "/index.html"
}
]
}
Source: https:/
- If
vercel.jsonalready hasrewrites, merge this entry into the existing list rather than replacing your rules. - If your
vercel.jsonsetscleanUrlstotrue, Vercel says not to include the file extension, so/index.htmlbecomes/. - Commit and push, or in Lovable or Bolt ask: "Add a vercel.json at the project root with a rewrite of /(.*) to /index.html." Let Vercel redeploy.
What the docs don't spell out
- Your images, JavaScript and CSS keep working. Vercel gives "precedence … to the filesystem prior to rewrites being applied," so real files are served first and only unknown paths fall through to
index.html. (vercel.json reference (opens in a new tab)) - Real 404s become your app's job. After the rewrite, every unknown path returns your app instead of Vercel's error, so add a catch-all "not found" route in your router. This follows from the rewrite sending all paths to
index.html. (Vercel Vite guide (opens in a new tab)) - Vercel prefers multi-page builds for production. The same guide says "Deploying your app in Multi-Page App mode is recommended for production builds." The rewrite is the quick fix. (Vercel Vite guide (opens in a new tab))
How to check it worked
- Open
https://yourapp.com/some-inner-pagein a new tab and refresh. It loads instead of showingNOT_FOUND. - Open a made-up path. Your app's own not-found screen appears.
- In DevTools' Network tab, a JavaScript or image file still returns the file itself, not the HTML page.
- Open a deep link the way your users will, such as from an email, a payment provider's success URL or a bookmark, in a private window. It should load the right page, not the home page or an error.
Sources
- https:/
/ :vercel. com/ docs/ errors/ NOT_ FOUND (opens in a new tab) NOT_FOUNDdefinition, 404 code - https:/
/ : SPA deep-linking note,vercel. com/ docs/ frameworks/ frontend/ vite (opens in a new tab) vercel.jsonrewrite,cleanUrlsnote, Multi-Page App recommendation - https:/
/ :vercel. com/ docs/ project- configuration/ vercel- json (opens in a new tab) rewritesproperty, SPA example, filesystem precedence
Related fixes
Tool to consider: Vercel.
Deploy Without Errors Pack
Environment variables on Vercel, Netlify and Replit, SPA refresh rewrites, npm peer dependency errors and domain setup.
Secure checkout by Stripe
One-time payment through Stripe. Priced in USD. Local taxes such as UK VAT may be added at checkout.