Skip to content
By stack3 min read

Vite hosting: from npm run build to a live site

Short answer

Vite is a build tool, and after npm run build its project is static files in the dist folder. You upload the contents of that folder to public_html on any hosting plan, with no Node.js needed on the server. If the app is a single-page app with client routing, add a rule in .htaccess that sends routes back to index.html. Variables starting with VITE_ are baked into the code at build time and visible to visitors.

ArabyHost teamLast updated: ShareWhatsAppXLinkedIn
Contents
  1. What are you actually hosting?
  2. Deploying step by step
  3. A site in a subfolder
  4. Environment variables
  5. Updating after the first deploy
  6. Limits to know
  7. On ArabyHost

Many modern projects are built with Vite without their owners knowing: the React, Vue and Svelte starters, and what tools such as Lovable and Bolt generate. The good news is that hosting them is about as easy as it gets, because what is published is not the project but its build output.

What are you actually hosting?

In the project After npm run build Where it runs
React, Vue or Svelte with no server Static files in dist/ Any plan
A custom server with Vite (SSR) A Node.js server and static files AI and developer plans
A separate API next to the front end Another project Depends on its language

Deploying step by step

  1. Build on your computer:
npm ci
npm run build
  1. Upload the contents: zip the contents of dist/, so that index.html is at the top of the archive. In cPanel open Files, then File Manager, go into public_html, upload the file and choose Extract.
  2. Rewrite rule: if the app uses client routing such as React Router or Vue Router, create an .htaccess next to index.html:
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.html [L]
</IfModule>
  1. Test: open an inner link directly and refresh the page.

Without the rule you get a 404 on page refresh. The same steps in more detail are in the React deploy guide.

A site in a subfolder

If the site will live at example.com/app/ rather than the domain root, set the base option before building:

export default defineConfig({ base: "/app/" });

Then change RewriteBase and the last line of .htaccess to /app/. Forgetting this option is the first cause of a blank page after deploy.

Environment variables

  • Variables starting with VITE_ are read from the .env.production file on your computer at build time and baked into the JavaScript files.
  • Changing a value means rebuilding and uploading again.
  • Everything starting with VITE_ is public. The API address and publishable keys belong here; secret keys belong on a server.

If the site appears without its data, the variables were missing at build time: see environment variables not loaded.

Updating after the first deploy

File names in dist/assets/ change with every build. When updating, delete the old assets folder and then upload the new one, so files do not pile up towards your account’s file count limit. Anyone who wants automatic updates builds in GitHub Actions and uploads the output.

Limits to know

  • No SSH on the ordinary plans, so the build happens on your computer.
  • A project with a custom server (SSR) needs Node.js, meaning the AI and developer plans.
  • No Docker and no root.

On ArabyHost

Vite output runs on every plan, served by LiteSpeed with a free automatic SSL certificate and daily backups. If your project has an API, PHP runs on the same plan, and Node.js and Python on the AI and developer plans. The Araby AI assistant reads the error log and explains it.

Prices are shown in your currency on the pricing page, and the renewal price is the price you signed up at. Framework pages: React, Vue and SvelteKit.

FAQ

Do I need Node.js on the hosting for a Vite project?

No. Node.js is needed on your computer to run the build only. The output is HTML, JavaScript and CSS files any web server can serve, so it runs on the smallest shared plan.

Why do I get a blank page after uploading the dist folder?

The most common cause is that the site sits in a subfolder and the base option is still at its default, so the browser asks for files at the domain root. Set base in vite.config to the folder path and rebuild. The second cause is uploading the folder itself instead of its contents.

Should I use vite preview to run the site on the server?

No. That command is for previewing the output on your computer and is not a production server. In production the web server serves the dist files directly.

Where do I put an API key in a Vite project?

Not in a variable starting with VITE_: everything with that prefix is baked into the JavaScript files and visible to any visitor. Secret keys belong on a server: a small PHP function or a Node.js API that the app calls.

Useful? Share it with someone who needs it:WhatsAppXLinkedIn

Read next

Ready to put your idea online?

Fast, isolated hosting, support that understands you, and an AI assistant that fixes problems with you.