This is a common issue with SPAs which occurs while working with child paths/routes. This is not specific to vercel and even occurs on other platforms as well, Here is something you can try with vercel:

Create a vercel.json file within the root folder of your project. Add this config to the file:

{
  "rewrites": [
    { "source": "/(.*)", "destination": "/" }
  ]
}

As mentioned in this doc as well:

"rewrites" specifies the rules for URL rewrites. { "source": "/(.*)", "destination": "/" } tells Vercel that for any URL path that matches /(.*) (essentially any path), redirect the request to the root path (/).

Answer from Chinz on Stack Overflow
🌐
Vercel
vercel.com › templates › react › vite-react
Vite - React
This directory is a brief example of a Vite/React site that can be deployed to Vercel with zero configuration.
🌐
Vercel
vercel.com › vercel documentation › supported frameworks › frontends › vite
Vite on Vercel
2 weeks ago - export default defineConfig(() => { return { define: { __APP_ENV__: process.env.VITE_VERCEL_ENV, }, }; });
Discussions

reactjs - How to deploy React TypeScript app to Vercel with Vite - Stack Overflow
I'm trying to deploy a React TypeScript project to Vercel, building with Vite. However, Vercel doesn't install devDependencies during build time like Heroku does, so it doesn't know what "vite... More on stackoverflow.com
🌐 stackoverflow.com
Deploying Vite react app on Vercel doesn't show up Firebase related env variables
You're right not to push your .env file to GitHub. But Vercel still; has to be aware of those values, so we add them separately. Your Vercel config has its own Environment Variables. They're in: https://vercel.com/MY-USERNAME/MY-PROJECT-NAME/settings/environment-variables (not a link) Add a new one with the key VITE_APIKEY and value being your private Firebase key. Repeat for any other variables you need. You can set different key/value pairs on Production and Preview environments, but for now keep them all available everywhere. Full docs: https://vercel.com/docs/projects/environment-variables More on reddit.com
🌐 r/react
10
9
January 4, 2024
Cheapest and easiest way to deploy a simple Vite React app?
Try out Netlify (Y) More on reddit.com
🌐 r/react
37
40
March 25, 2024
express - How to deploy a Vite + React SSR application on Vercel? - Stack Overflow
I am trying to deploy a Vite app on vercel which is using express to do SSR. The express server runs successfully, vercel however doesn't deploy the built files (dist/server and dist/client, see th... More on stackoverflow.com
🌐 stackoverflow.com
March 25, 2025
🌐
Build with Matija
buildwithmatija.com › blog › how-to-deploy-a-vite-react-app-on-vercel-and-connect-to-an-external-api-server
How to Deploy a Vite-React App on Vercel and Connect to an External API Server | Build with Matija
November 15, 2024 - After deploying, try accessing your app’s /api routes to confirm they are correctly proxied to your external API server. For example, if your frontend requests /api/brands, it should now return data from http://api.example.com/brands. Use Developer Tools: Check your Network tab in Developer Tools to see where requests are being routed. Verify Deployment: Ensure that your vercel.json file is committed to your repo and included in your deployment.
🌐
Medium
medium.com › @matijazib › how-to-deploy-a-vite-react-app-on-vercel-and-connect-to-an-external-api-server-7976c3d6ea64
How to Deploy a Vite-React App on Vercel and Connect to an External API Server | by Matija Žiberna | Medium
November 16, 2024 - Instead, you’ll need to set up a reverse proxy to route API requests from Vercel to your external API server. In this guide, I’ll show you how to use Vercel’s rewrites to forward requests to your API.
🌐
YouTube
youtube.com › how dev you
Deploy Vite + React App to Vercel || Add Custom Domain to React App - YouTube
Deploy Vite + React App to Vercel || Add Custom Domain to React App00:00 - Intro | Aim[Deploying React App | Adding Custom Domain SubDomain]00:26 - Creating ...
Published   July 14, 2023
Views   9K
🌐
GitHub
github.com › internetdrew › vite-express-vercel
GitHub - internetdrew/vite-express-vercel-starter: A starter template for building and deploying a Vite + React + Express application on Vercel, with details on configs to power your project. · GitHub
August 9, 2025 - import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; // https://vite.dev/config/ export default defineConfig({ plugins: [react()], server: { proxy: { '/api': { target: `http://localhost:3000`, changeOrigin: true, }, ...
Starred by 16 users
Forked by 6 users
Languages   TypeScript 38.7% | CSS 37.8% | JavaScript 15.7% | HTML 7.8%
Find elsewhere
🌐
Roblog
robiul.dev › deploy-vite-react-app-on-both-github-pages-and-vercel
Deploy Vite React App on Both GitHub Pages and Vercel
November 20, 2023 - You can name it anything, but ensure it starts with VITE_ the preset. Leave other settings as default and click "Deploy." Your React application will deploy within seconds, providing two to three preview links.
🌐
YouTube
youtube.com › watch
How To Deploy A React App To Vercel (Simple) - YouTube
In this video I will teach you guys how to deploy a vite react app to Vercel in order to see your projects live.🌟 Support My Work: https://buymeacoffee.com/...
Published   March 11, 2025
🌐
YouTube
youtube.com › watch
Deploying a Vite-based React & Typescript app on Vercel in 30 seconds - YouTube
0:00-0:17 Intro0:17-0:34 Clicking on the 2 buttons needed to deploy0:34-0:49 Letting Vercel do it's thing 0:50-1:26 Celebrate!Well, it was super quick slingi...
Published   April 7, 2023
🌐
Stack Overflow
stackoverflow.com › questions › 72001670 › how-to-deploy-react-typescript-app-to-vercel-with-vite
reactjs - How to deploy React TypeScript app to Vercel with Vite - Stack Overflow
I've followed the Vite guide for Vercel deployment. It feels very odd to include Vite and TypeScript as a normal dependency, so that it'll be included in the bundle. I know it's possible to configure Vite to exclude certain dependencies on your bundle, but is this really the way to do it? ... https://twitter.com/dan_abramov/status/1098234219506085889 https://twitter.com/dan_abramov/status/1098234004954857472 · He's talking about CRA, but the same principle applies here to vite.
🌐
Gautham Dev Diaries
gautham10.hashnode.dev › react-vite-app-a-comprehensive-guide-from-creation-to-vercel-deployment
React Vite App: A Comprehensive Guide from Creation to Vercel Deployment
February 7, 2024 - In our case, it is React-vite-app that we want to deploy, be advised it is the same name of the GitHub repository that I had created so make sure to select the same GitHub repository name that you had created to deploy. After importing, Vercel redirects you to another screen asking some details about the project.
🌐
Reddit
reddit.com › r/react › deploying vite react app on vercel doesn't show up firebase related env variables
r/react on Reddit: Deploying Vite react app on Vercel doesn't show up Firebase related env variables
January 4, 2024 -

About app :-

  1. React App

  2. created using vite

  3. Uses Firebase

  4. Deployed on vercel

How am I handling env variables :-

  1. I'm setting env variables on vercel (vercel > settings > environment variables )

  2. Env variables are basically firebase config variables (like apikey, appid, etc.)

  3. For example, one of my env key looks like :- VITE_APIKEY. (I've prefixed all env keys with VITE_).

  4. So, this way I don't push my .env file to github. (I'm confused though, on the fact that whether one should make .env file available onto github since I'm directly setting envs on vercel).

  5. In my firebase.ts file, I access variables like this :-

const env = import.meta.env;

const firebaseConfig = {apiKey: env.VITE_APIKEY,};

6. (ISSUE) The env variables are not working. This firebase.ts file is pushed to github as it is (and thus vercel). However, in some other discussions, I found env variables being accessed like this :- process.env.VITE_APIKEY. So, I tried setting the firebaseConfig keys in above file by using process.env rather than import.meta.env. But that didn't work. Indeed, in the latter case, I got error saying that the env variable doesn't exist. So, I don't know what am I missing here.

To conclude,

When using import.meta.env.VITE_APIKEY , the website atleast works. Just firebase interaction is not working. (The entire thing works on local).

When using process.env.VITE_APIKEY, nothing works.

Additional Context :- 1. This is how my vite.config.ts file is defined

export default defineConfig({plugins: [react()],})

I'd really be thanful if I could get some help on how can I make my envs work. Also, I can move this question if it wouldn't be relevant in this sub.

🌐
Koida
reactjs.koida.tech › deployment-and-web-hosting › lesson-2.-deploying-a-react-vite-app-to-vercel-from-vercel-cli
Lesson 2. Deploying a React Vite App to Vercel from Vercel CLI | ReactJS-The Beginner Master Class
May 5, 2025 - What’s the name of your existing ...ects-dc94ec84.vercel.app [935ms] 📝 To deploy to production (words100.vercel.app), run `vercel --prod`...
🌐
Kitemetric
kitemetric.com › blogs › deploying-your-vite-and-react-app-to-production
Deploying Vite & React Apps: Netlify, Vercel, DigitalOcean | Kite Metric
May 5, 2025 - Learn how to deploy your Vite and React application to production using Netlify, Vercel, or DigitalOcean. This comprehensive guide covers setup, build processes, and CI/CD pipelines for a seamless deployment experience.
🌐
Reddit
reddit.com › r/react › cheapest and easiest way to deploy a simple vite react app?
r/react on Reddit: Cheapest and easiest way to deploy a simple Vite React app?
March 25, 2024 -

I have a very simple Vite React app with no database (it uses Supabase). What's the easiest and possibly cheapest way of deploying it? Note that this is for demonstration purposes only, so I don't expect much traffic (if any at all).

🌐
Stack Overflow
stackoverflow.com › questions › 78098996 › how-to-deploy-a-vite-react-ssr-application-on-vercel
express - How to deploy a Vite + React SSR application on Vercel? - Stack Overflow
March 25, 2025 - Vercel cannot use app.listen(). In your project directory, create a file vercel.json containing: { "rewrites": [ { "source": "/(.*)", "destination": "/api/index.js" } ], "functions": { "api/index.js": { "includeFiles": "dist/client/**" } } } rewrites forwards all requests to a serverless function. includeFiles allows to serve the directory and access files. Deploy as usual.
🌐
Reddit
reddit.com › r/backend › how to deploy a react + vite + typescript project on vercel (free plan) — any setup tips?
r/Backend on Reddit: How to deploy a React + Vite + TypeScript project on Vercel (free plan) — any setup tips?
October 13, 2025 -

Hey everyone 👋

I’m currently working on a frontend project built with React + Vite + TypeScript.

I’ve read the Vercel docs and noticed that Vercel mainly focuses on Next.js, but I’m wondering if there’s an official or recommended way to deploy Vite-based projects there, especially on the free plan.

Here’s what I’ve tried so far:

•	Built the project using npm run build — everything works fine.

•	The output is in the /dist folder (default for Vite).

•	I saw some mentions that it’s possible to host it on Vercel with static export, but I’m not sure about the right configuration for routing and environment variables.

My questions:

1.	Does Vercel free plan fully support React + Vite projects?

2.	Are there any limitations (build time, bandwidth, or file size)?

3.	If Vercel isn’t ideal, what’s the best free alternative (Netlify, GitHub Pages, Cloudflare Pages, etc.) for Vite apps?

4.	Also, I’ll need a simple free backend — would you recommend something like Render, Railway, or Supabase for small APIs?

Thanks in advance! 🙏 I’d really appreciate any guidance or setup examples.

🌐
DEV Community
dev.to › ngduc › try-react-18-with-vite-typescript-and-vercel-okg
Try React 18 with Vite, Typescript and Vercel - DEV Community
October 20, 2023 - yarn create @vitejs/app my-project --template react-ts cd my-project ... As @types/react doesn't understand the new React 18's APIs or types yet, we need to update "tsconfig.json" file: after "jsx": "react" add: ... yarn dev vite v2.3.7 dev ...
🌐
YouTube
youtube.com › nono martínez alonso
DEPLOY to VERCEL Vite, React & TypeScript Apps — Creative AI & Coding with Nono · Live 112 - YouTube
Live streams on creative coding and machine intelligence with Nono Martínez Alonso.==================LINKS==================— Code at https://github.com/nono...
Published   January 12, 2026
Views   243