Link to home
Start Free TrialLog in
Avatar of David Barman
David BarmanFlag for United States of America

asked on

Moving from dev to prod with React app

I have a ReactJS app I’ve built in dev that works. The development environment has NodeJS installed on the Windows PC computer. Thus, the backend Express database API is able to run. I have to start that manually in this dev environment. Then I am able to browse to the development ReactJS application and it all works.

For a production system, I would need the backend portion running automatically so the React App would work whenever accessed.  Since I have never done this before, I don't know what requirements are needed to facilitate this project.

For example: Can it run on a shared web hosting account (ie. Godaddy or something comparable?) or does it require a dedicated server?, etc.  If it can be run on a shared hosting server, what is the process to get the backend portion installed, etc.

Instructions or guidance on what is needed to move this from the dev environment to a production environment is greatly appreciated.
Avatar of leakim971
leakim971
Flag of Guadeloupe image

here the doc : https://create-react-app.dev/docs/deployment/

npm run build creates a build directory with a production build of your app. Set up your favorite HTTP server so that a visitor to your site is served index.html, and requests to static paths like /static/js/main.<hash>.js are served with the contents of the /static/js/main.<hash>.js file. For more information see the production build section.

so you just need to "run npm build" instead the manual/usual "npm start" and copy the content of this build folder to a simple web server.
Godaddy os something comparable is fine
Avatar of David Barman

ASKER

I can do that just fine for the React App.  My issue or lack of understanding is how to handle the NodeJS database backend.  I can build that as well, but how do I install it and run it on the server for the React app to use it to access the database?
how do you start your dev "NodeJS database" manually currently?
you need to find a host service proposing the same "NodeJS database", they will provide a hostname, port, username and password
you just need to switch from you to them
I don't think it's that simple.  The database is not the issue (MySql).  I can upload the database without an issue.  The question here is one: how do I get the NodeJS application running on the server.  Two: How do I get the React App to communicate with the backend.  I believe in the development environment it uses a reverse proxy for the two to communicate.
you should start choosing a hosting service
they provide the "tools" answering your question
that can be just a CLI, a set of tools to use or your command line or a WEB UI

Try "heroku" for example : https://devcenter.heroku.com/articles/getting-started-with-nodejs
Is that a shared hosting or dedicated hosting environment?  Are there other options that you have knowledge of besides heroku?
Heroku : https://www.heroku.com/what
Heroku is a cloud platform that lets companies build, deliver, monitor and scale apps — we're the fastest way to go from idea to URL, bypassing all those infrastructure headaches.
AWS EC2 : https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-up-node-on-ec2-instance.html
Google Cloud : https://cloud.google.com/nodejs/
So it sounds like I would require a "specialized" type of hosting for this application??
I assume a Ubuntu self hosted solution is an option?

Are there any generalized guides that are available that explain what is required?  This seems like it would be a common type of setup, or not?
So it sounds like I would require a "specialized" type of hosting for this application??

You right, NodeJS run on specific hosting
If it was only ReactJS, Goddady would be fine

I assume a Ubuntu self hosted solution is an option?
yes, should be

you need to install node on that server, MySQL, I think you don't need more
Heroku provide ready to use environment
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.