UK web hosting · 24/7 live chat Black Friday + Cyber Monday: hosting + free domain £19.99 Open a ticket Client login

Guide

How to host a React or Vite app on shared hosting

By Limitless Hosting · 5 min read · Updated 18 November 2026

A React or Vite app builds into a folder of static files, so you can host it on shared hosting by running the build, uploading the output and adding a rewrite rule so page routes load index.html. Set the correct base path, upload the dist folder to your web folder, and add a rule to the .htaccess file. Most blank-page problems come from a wrong base path or missing rewrite rule.

See the plans

The basics

Why it works on shared hosting

React and Vite are tools for building modern websites with JavaScript. During development, a small server runs on your computer. For the live site, you run a build command, and the tool produces a folder, usually called dist or build, containing plain HTML, CSS and JavaScript files. That folder is all a visitor’s browser needs.

Because the output is static, any web server can serve it, including the LiteSpeed server on our shared plans. You do not need Node.js running on the host. You only need to get the files there and make sure addresses behave properly.

The one catch is routing. A single-page app handles pages inside the browser, so a direct visit to a path such as /about has no matching file on the server. The server must be told to send such requests to index.html and let the app take over. That is the rewrite rule covered below.

Deploying

Build and upload, step by step

Set the base path

If the app lives at the root of your domain, the default works. If it lives in a folder, set the base option in the Vite config to that folder.

Run the build

In the project folder, run the build command, usually npm run build. A dist folder appears.

Check the output

Open the dist folder. It should contain an index.html and an assets folder. You can preview it locally with the preview command.

Upload the files

Copy the contents of dist into your site’s web folder with rsync over SSH or with SFTP. See what SFTP is and how to use it.

Add the rewrite rule

Create or edit the .htaccess file in the web folder so unknown paths load index.html, as shown in the next section.

The rule

The rewrite rule for single-page apps

Add this to the .htaccess file in the folder where you uploaded the app. It sends any request that does not match a real file or folder to index.html, so your app’s routes work on a direct visit or a refresh.

.htaccess for a single-page app
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]

If the app is in a subfolder, change the base and the final path to match. After saving, visit a deep route directly and refresh it. If the page loads, the rule works.

Troubleshooting

Common problems and fixes

ProblemLikely causeFix
A blank pageWrong base path, so scripts do not loadSet the correct base and rebuild
404 on refresh of a routeNo rewrite ruleAdd the .htaccess rule
Assets return 404Files uploaded to the wrong folderUpload the contents of dist, not the dist folder itself
Old version showsBrowser or server cacheHard refresh and clear caches
API calls failThe app expects a backend that is not thereHost the API separately or use a Node.js app
Mixed content warningsHard-coded http addressesUse https addresses

Worked example

A worked example: a small booking page

Alex builds a one-page booking app with React and Vite, using Claude Code for much of the code. Locally it works perfectly. He runs the build, uploads the dist folder’s contents to his web folder, and visits his domain. He sees a blank white page.

He opens the browser’s developer tools, and the Console shows that the JavaScript files return 404 errors. The app was built expecting to live at the root, but he had uploaded it into a folder called app. He sets the base option to /app/, rebuilds and uploads again.

The page loads. He then visits /app/bookings directly and gets a 404, so he adds the rewrite rule with the right base. Refreshing any route now works. Total time: twenty minutes, including finding the cause by reading the Console.

Environment settings

Keys, settings and what not to expose

Anything in a front-end app is visible to anyone who opens the browser tools. Never put private keys, passwords or secret tokens in React or Vite code, even in environment variables that are built into the bundle. Only public values, such as a public API address or a public analytics ID, belong there.

If your app needs private data or secret keys, it needs a back end that holds them, such as a small Node.js or Python app, and the front end should call that. Our Node.js hosting page and guide to running a Node.js app cover that side.

Check build-time variables before every deploy. A key pasted in during testing is easy to forget, and once it is in a published bundle it should be treated as leaked and replaced.

Checklist

A React or Vite deploy checklist

  • The base path matches where the app will live
  • The build runs cleanly with no errors
  • The contents of dist are uploaded, not the folder itself
  • The .htaccess rewrite rule is in place
  • A deep route loads on direct visit and refresh
  • No secrets are in the front-end code
  • HTTPS shows the padlock
  • You tested on a phone

Automating

Deploying automatically on every push

Once the manual deploy works, you can automate it. A GitHub Actions workflow can check out your code, install dependencies, run the build and upload the dist folder over SSH whenever you push to your main branch. You write the workflow once, and every later change goes live without you touching a terminal.

Use a dedicated SSH key for the workflow, store the private half as a secret in the repository settings and give it access only to the one account. Never reuse your personal key for automation. Run a dry run first so you can see what the workflow will change.

Keep a simple rollback in mind. Tag each release, and keep the previous build, so that if a deploy breaks the site, you can put the last good version back in a minute. Our deploy guide shows the full workflow.

Performance

Making the build fast for visitors

A built React or Vite app is already optimised, but you can do more. Split your code so each page loads only what it needs, compress images before adding them, and use modern image formats. Check the bundle size after the build, and look for large libraries you could replace.

Ask the server to compress text files and to cache assets that rarely change. Vite gives built files names with a hash, so you can safely cache them for a long time. Test the live site with a free speed tool on a phone, and fix the biggest items first.

Host your project on UK servers

SSH, Node.js and Python selectors, free SSL and live chat open 24/7 on every plan, from 84p a month (£10.03 billed yearly).

See the plans

FAQ

Common questions

Can I host a React app on shared hosting?

Yes. Build it into static files and upload them. You need a rewrite rule so routes load index.html.

Do I need Node.js on the server?

Not for a built single-page app. Node.js is only needed if you run a back end.

Why is my page blank?

Usually a wrong base path, so scripts and styles cannot load. Check the Console in developer tools.

Why do I get 404 when I refresh a route?

The server looks for a file at that path. Add the rewrite rule so unknown paths load index.html.

Where do I upload the files?

To your site’s web folder, such as public_html. Upload the contents of dist.

Can I keep secrets in environment variables?

Not in front-end code. Anything built into the bundle is public. Use a back end for secrets.

Can I deploy automatically?

Yes. A GitHub Actions workflow can build and upload over SSH on every push.

Deploy your project on a plain yearly price

SSH, Node.js and Python selectors and free SSL on every plan, with a 15-day money-back guarantee.

See the plans .co.uk and .uk domains £9.99

From 84p a month, billed yearly
15-day money back
Get started