backend/
├── node_modules/
├── server.js
├── package.json
└── ...
frontend/
├── node_modules/
├── public/
├── src/
├── package.json
└── ...
...
-
Create a new
Web Serviceon Render.
-
Choose the GitHub repository to deploy from.
-
Set the following configurations:
- Language:
Node - Root Directory:
backend - Build Command:
npm install - Start Command:
node server.jsNote: Replace
server.jswith the main file of the backend project.
- Language:
-
Click on
Deployto deploy the backend API.
-
Click on the
New Projectbutton.
-
Choose the GitHub repository to deploy from.
-
Set the following configurations:
- Framework Preset:
Create React App - Root Directory:
frontend - Build Command:
npm run build - Output Directory:
build
- Framework Preset:
-
Click on
Deployto deploy the frontend project.
Note: The backend API URL can be configured to be used in the frontend project by using the
.envfile:
- Create a
.envfile in the frontend project with the following content:REACT_APP_API_URL=https://localhost:5000
Use the
process.env.REACT_APP_API_URLin the frontend project to access the backend API URL.After deploying the frontend project on Vercel, add the
REACT_APP_API_URLenvironment variable in the Vercel project settings and set the value to the backend API URL on Render.
Voilà! The MERN app is now deployed on Render and Vercel. To use the app, access the frontend URL provided by Vercel. (The backend API URL will be implicitly used by the frontend app.)