How to setup React app in the cpanel Print

  • 0

Deploying a React app (Create React App, Vite, Next.js static export, etc.) on cPanel is simple because it’s just static files after building. Here’s the exact process:

  1. Log in to your cPanel account.
  2. Open File Manager and go to the folder where you want the site to live (usually public_html for the main domain or a subfolder like public_html/myreactapp for addon domains/subdomains).
  3. In your local computer, open the terminal inside your React project and run the build command:
    npm run build (or yarn build / pnpm build)
  4. This creates a folder named build (Create React App) or dist (Vite, Remix, etc.).
  5. Compress the contents of the build/dist folder into a ZIP file (do NOT zip the folder itself, zip everything inside it).
  6. Back in cPanel File Manager, click Upload and upload the ZIP file.
  7. After upload finishes, right-click the ZIP file → Extract → extract the files directly into your chosen folder (public_html or the subfolder).
  8. If you are using React Router (browserHistory / client-side routing), create a file named .htaccess in the same folder with this content:

apache

RewriteEngine On

RewriteBase /

RewriteRule ^index\.html$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule . /index.html [L]

 

  1. Delete the ZIP file to save space (optional).
  2. Visit your domain or subdomain — your React app is now live!

That’s it. No Node.js selector needed since the built React app is purely HTML, CSS, and JavaScript.


Was this answer helpful?

« Back