Contents
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
- Build on your computer:
npm ci
npm run build
- Upload the contents: zip the contents of
dist/, so thatindex.htmlis at the top of the archive. In cPanel open Files, then File Manager, go intopublic_html, upload the file and choose Extract. - Rewrite rule: if the app uses client routing such as React Router or Vue Router, create an
.htaccessnext toindex.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>
- 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.productionfile 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.