How to Deploy a React App on cPanel

Deploying a React app on cPanel is mostly a static build upload — unless you need SSR. For Create React App, Vite, or similar SPA builds, you upload the production build or dist folder and fix client-side routing.

Build locally

  1. Run npm run build (or pnpm/yarn equivalent).
  2. Confirm the output folder (build or dist).
  3. Test the build with a static server if possible.
  4. Note environment variables baked in at build time (VITE_ / REACT_APP_).

Upload to cPanel

  • File Manager or FTP into public_html (or a subdomain folder)
  • Upload contents of the build folder (not necessarily the folder name itself)
  • Ensure index.html sits at the web root you intend

SPA routing (.htaccess)

For React Router browser history, add an Apache rewrite so deep links load index.html:

Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]

Common failures

  1. Wrong homepage/base path — set Vite base or CRA homepage for subfolders.
  2. API calls blocked by mixed content (HTTP API on HTTPS site).
  3. Caching old bundles — hard refresh after deploy.
  4. Uploading source instead of the build output.

Related learning

Backend-ish student projects sometimes start on desktop — Tkinter restaurant system — then move to web. Career-wise, deployment habits show up in cloud roles.

FAQ

Can cPanel run npm start?
That’s for development; production uses the static build (unless you have Node hosting).

Do I need Node on the server?
Not for a pure SPA static deploy.

What about SSR Next.js?
Needs Node hosting — different from classic cPanel static.

Build locally, upload the static output, fix base path and SPA rewrites, then verify deep links. That’s the reliable React-on-cPanel path.

Disclaimer

Sengideons.com does not host any files on its servers. All point to content hosted on third-party websites. Sengideons.com does not accept responsibility for content hosted on third-party websites and does not have any involvement in the same.

LEAVE A REPLY

Please enter your comment!
Please enter your name here
Are you human? Please solve:Captcha