Stay hydrated out there
Diving Right In
While working on a personal project called Punchstarter, a Kickstarter clone app, I struggled t...
For further actions, you may consider blocking this person and/or reporting abuse
Hello, thank you for your article. I was stuck all day long and it helped me. However, there are few things I would like to add, if I may, to complete the information :
For the rest, everything is exact. Thanks again !
can you explain more about "You don't need Node on your remote server"?
can i build an app with mySql + node + react - run build, and deploy the app on c-panel, or the c-panel deploy only react apps with static data, not apps that use database?
and i`m not talking about a vps hosting, but a regular shared hosting.
What he answered and you had asked are not the same.
He just pointed out that in a React App, we need to compile the files using node to generate build files inorder to work in production.
Generally in VPS or private cloud the build process is took place in server where we explicitly have node installed. He intends to tell that you can build your React App in your local machine and just copy the build files to the production.
Hope I cleared your first doubt.
Everything is working well except the nested route like hahahah/products/2836276 is not receiving response from backend. Am fetching data from SQL database using PHP as backend. But it's working in localhost. All the other routes like hahahah/products are able to fetch data though. Please help
Not sure if you know this or not, but when people contact GoDaddy for help with deploying a React app to their system... they refer us to this article... and they have no information other than that... so thanks for writing this!
I didn't know that! That's good to know :)
Hey, thanks for this post, though I would like to know how to deploy having NodeJS server. I need to deploy in cpanel becaue I have already a Dedicated Server for all my clients, the most of them use WordPress and I'm trying to switch, but while that happen I don't want another expense.
This tutorial is good, but it really doesn't explain how to do it using Node. I have Node Running already, but I don't know the exact path and setting to upload the build and connect it with node in another folder in the same account.
I'm really new on this, maybe it's easy for you but I've tried everything, even read the documentation for deploy but still don't understand.
Hi there, I know cPanel has an option to deploy Node, however I haven't looked into this just yet. I'll be sure to tag you when I look into it!
Have you looked into that?
😱
Brooooo, can you explain me how would you deploy Node.JS in C-Panel?
It depends from hosting to hosting.
I've asked some experienced developers how to do this and they weren't sure. Having my project run on my own site using cpanel is much more fulfilling than just sending it heroku, in my opinion, and the end product feels more authentic. Thanks for keeping it so concise also!
Really glad this could help!
This was a fantastic tutorial. It worked perfect, except for one caveat. In step 3. Create the build File, the command "npm build" didn't work. I got the following:
npm build
called with no arguments. Did you mean tonpm run-script build
?So I changed it to "npm run build" and it worked fine!
I also used Filezilla to transfer the contents of the build folder into a sub-folder of my public_html directory, because I have a number of sub-domain folders in my public_html directory. Once I refreshed my browser, the domain showed up perfectly with my React application all intact!
try "npm run build"
Great article, I found it super helpful.
I was wondering however, is there any way for cPanel to hide environment variables while hosting only a React site?
I have a React app I would like to be deployed, but I have environment variables that will be visible in my build, and this visible on the browser for anyone to access.
Please how did you added the environment variables?
did you find a way to add environment variables?
Did you find a way to implement this?
Not strictly with React, I'm going to try to create a Node Express backend and hide the API keys there
This worked wonderfully. Thank you. I do have a question though. If I make updates to the app on my localhost....do I need to run npm install and build agian or can I just re upload the contents of the build folder
You need to build it again to generate build files for the updated content!
But build folder of react application is very small . Does it contain all my sources and required JS libraries ? I copied all this content to my hosting public_html folder . Created .htaccess file . But when open my site in browser it show empty screen and error in console -
2.b5ad5a0d.chunk.js:1 Uncaught SyntaxError: Unexpected token '<' " insidgenerated JS file in build files.
But all application run perfect in development mode .
Thank you so much for this helpful post! I was able to get it up and running thanks to you.
Although I was wondering, are there any ideas as to how to automate this process? To manually have to get the build files every time seems like a pain. I assume there must be a way with GitHub actions/web hooks.
Gonna test this out on Bluehost with Next.js - Heroku not hosting images is proving to be a pain. Thanks for the article - I'll let you know how it goes.
For sure, let me know!
This was extremely helpful to my project! Thank you for sharing!
I was wondering where did you find that tidbit about .htaccess ? I was hoping to dive more into that step
I looked all around, and can't remember all my resources, but at the time I remember this article being helpful: hostgator.com/help/article/how-to-...
That file essentially communicates with the server and makes sure all your routing works, especially if you're using react router for example.
Awesome! Thanks again!
Hey there, thank you very much for your article, I was following the steps you described on how to deploy React App on to the shared hosting I have with a2 Hosting, however the app is working but only the static content whatever is dynamic is not rendering throwing an error this.state.data.map is not a function. App is working flawlessly on heroku as well as on my local machine. But as soon as I put it on a2Hosting - it crashes. If I stop dynamic content and replace it with static it works fine. I opened several tickets with them but didn't get any logical answer on why this isn't working. They were giving me advances to put data into array (it is already an array) so I have no clue why this isn't working. May be you have a solution before I get rid of a2 hosting and move somewhere else? Thank you in advnace
where does your app fetch the data from?
Hi there,
The tutorial I searched for.
My domain is "aaaaaaa.com".
I modified the package.json by including the "homepage" line pointint out to "aaaaaaa.com"
I run "npm run build". It created the build folder inside my React app.
I connected to my cpanel user. I opened the File Manager. Under my "public_html" folder I created a folder called "chat".
Inside this folder "chat" I uploaded the content of my build folder, including my static folder which contains both folder css and js (and their files).
6.a I modified the "public_html/.htaccess" file to add the content you shared with us.
6.b I modified the path to "index.html" to be pointed out to the "index.html" inside my chat folder:
RewriteEngine On
RewriteBase /
RewriteRule ^/chat/index.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /chat/index.html [L]
I went to the "aaaaaaa.com" webpage.
I couldn't directly see the chat. Instead, at "localhost:3000" I can directly see the chat.
It's clear I made a mistake but I don't know where I made it.
Could you gently help me, please?
Best regards.
When I load "aaaaaaa.com/chat" this message is showed at the console tab:
Uncaught SyntaxError: Unexpected token '<'
Can this message explain us why my chat is not seeing?
Hi,
Found it very useful.
It helped me to upload my files.
Thanks!
Awesome, I appreciate it.
I don't think your article shows a server.js. I have something like:
-public
--dist
---bundle.js
---styles.css
--index.html
--images
-server
--server.js
-src
--components
--app.js
-.babelrc
-package.json
-webpack.config.js
I don't think that the Build covers the server.js so where does this live and get activated at? Does anyone know a full instructional on this type of deployment? I opened port 3001 in cPanel, but my requests aren't going through on port 3001.
The
.htacess
was lifesaving!!!!!!!!!hi, I cant find where and how to create .htaccess file? I tried in public_html folder , it shows it has after creating but when I try to open it doesn't open.
I tried creating in my react app in public folder but it doesn't show on cpanel to upload.
Thank you for this awesome article. I have have issue with my react app after uploading it to C-panel, each page gives a 404 error when refreshed. Please ho can i solve this?
I am having the same issue. From what I can tell, it has to do with the server configuration. Somehow the server must be configured to redirect all page requests to index.html but I haven't figured out yet where to do that. Have you had any luck?
I'm having this same issue too please any luck with this?
Great guide for deploying React apps with cPanel! While cPanel is widely used, have you considered trying CyberPanel? It’s a powerful alternative that offers features like OpenLiteSpeed integration for faster performance, built-in support for Docker, automatic SSL, and a much more user-friendly interface. Plus, CyberPanel has a free version, which is a great advantage over cPanel's pricing.
Hey. Thanks for this tutorial. It has helped me immensely. However I had one question. With this tutorial I can now deploy a standalone React app in Cpanel. And Cpanel already supports standalone Nodejs app. But how can we deploy a MERN stack app in Cpanel? Any idea?
Great article Cris. Keep at it.
Many thanks for the information.
Hi there,
Can someone help me?
Suppose my React app is hosted at: http://pushstart/myapp
In order the routes works, how does would be my .htaccess file?
TIA
RewriteEngine On
RewriteBase /
RewriteRule ^index.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
into your .htaccess .
note: ./index.html when your index.html and .htaccess in same folder. if you have put your react app in some other folder then ./someotherfolder/index.html
Thanks Cris, worked nicely for me!
Al
Thanks a lot again.
Thanks, this helps a lot!
I tried this with Godaddy and it worked great, but now in A2 Hosting is not working, have your tried it? Any advice?
thanks bro, very helpful
Thank you so much for adding this content. It was so helpful especially after dealing with this issue for 2 days!
Glad I could help!
bro how to create a new subdomain and put inside another react ap , I tried it , but when I access to the new page after refreshing the page I got 404
that post is very grat
thank you for help pro
Thank you!
thank you very much you just saved me from lot of stress
Thank you for this very useful article.
Thanks master, this is useful hundreds and millions times, thanks!!
thanks for the toturial . I have a react app running on cpanel with the routers working fine but any time i refresh i get the error "Sorry, this page does not exist"
Page Reload is not working
when i reload same page 404 error showing
Same issue with me
hi,
thanks for this amazing article. but my question is how i create website using next.js(as frontend) and WordPress (as backend) and deploy this on cpanel
This is So great. Spot on. Thanks a lot 😄 😁 😄
Thanks a lot man.
I just run
Absolutely spot on, thanks SO much!
React routers are not working even after adding htaccess file . any body help me.
Im hosting thee build files on a name cheap shared hosting server
Thank you soo much. Being not completely from the web dev domain, I was stuck on how would I deploy my changes to cpanel for React Website and your blog just acted as life savior.
Thank you, work for me.
Thank you Cris! Super helpful and straightforward.
It worked for me. Awesome guide. Thanks a lot.
Hi it was great. Please learn how to build an api and how to connect it to the project.
Thanks so much for making this article. You saved me a ton of time, and I made an account here so I could say thanks. I wish all help articles could be this helpful, accurate, and concise.
My site not working danisoft.am error api
Hi, I have my React app running in public_html/react_app on Namecheap. Regarding the .htaccess file, can I just place it in the react_app folder?
I tried this on Goddady and it worked great, thanks! But in A2 Hosting is not working, have you tried it? Any advice?
Thank you so much for this.. Do we need to repeat this process for any new update ?
After a lot of search on this subject, a simple article like this, made my day 😆
Thanks a lot!
Hi Chrishanks.. I wonder if it is possible to upload the files in a subfolder(i.e domain.com/react)?
can you deploy the same way a react app that connected to mysql?
Thank you so much.
Very helpful and I got it finally.
Thank you so much for this post!
It solved my problem in a matter of minutes!
Thanks. Got it work out.
I need help, I can't get my application to work. I follow all the steps, but I keep getting the following error 503.