I'm building a web app using React.js and Node.js. I wanted to know that how I deploy my web application on a server? Like when I run it on my local server then it needs two server, one is for React.js and another is for Node.js. Is it goes same with deployment also?
2 Answers
No, you will only need one server (unless you're using a server side rendering framework like Next.js). If you used create-react-app, use should be able to run npm build and it'll create a static build.
Here's some relevant links:
1 Comment
You need to run script to build and bundle your client side by calling npm run build in terminal, then you should serve those build files in index/main file in backend side .
Then you can deploy your application.
You can read this awesome article to understand in depth:
https://www.freecodecamp.org/news/deploying-a-mern-application-using-mongodb-atlas-to-heroku/