Setup to Deploy React.js App on cPanel
š Setup to Deploy React.js App on cPanel
Follow these steps to deploy your React app on a cPanel server:
1ļøā£ Create and Build Your React App
-
Open a terminal or command prompt.
-
Navigate to the directory where you want to create the React app.
-
Go to the appās root directory:
-
Open package.json in a text editor and add your domain:
-
Install dependencies:
-
Build the production files:
2ļøā£ Add .htaccess for React Routing
Inside the public folder of your React app, create a file named .htaccess and add this:
š This ensures React handles routing properly (avoids 404 on refresh).
3ļøā£ Upload Files to cPanel
-
Log in to cPanel.
-
Open File Manager.
-
Go to the
public_htmldirectory (or the addon domain folder if using a subdomain/domain). -
Upload the contents of the
buildfolder (not the folder itself, just its contents). -
Save and confirm.
4ļøā£ Verify Deployment
-
Open your domain in the browser ā it should load your React app.
-
If you see issues with routing, double-check the
.htaccessfile.
Share
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Angry
0
Sad
0
Wow
0
