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:
- Log in to your cPanel account.
- 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).
- In your local computer, open the terminal inside your React project and run the build command:
npm run build (or yarn build / pnpm build) - This creates a folder named build (Create React App) or dist (Vite, Remix, etc.).
- Compress the contents of the build/dist folder into a ZIP file (do NOT zip the folder itself, zip everything inside it).
- Back in cPanel File Manager, click Upload and upload the ZIP file.
- After upload finishes, right-click the ZIP file → Extract → extract the files directly into your chosen folder (public_html or the subfolder).
- 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]
- Delete the ZIP file to save space (optional).
- 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.