![]() |
VOOZH | about |
In web development, creating a "Social Media Website" will showcase and utilising the power of MERN stack – MongoDB, Express, React, and Node. This application will provide users the functionality to add a post, like the post and able to comment on it.
Preview Image: Let us have a look at how the final output will look like.
👁 wf
Step 1: Create a directory for the backend by running the following command.
npm init social_backend
cd social_backend
Step 2: Initialize the Express project and install the following dependencies.
npm init -y
npm install express mongoose cors body-parser multer uuid
Folder Structure(Backend):
👁 baThe updated dependencies in package.json file of backend will look like:
"dependencies": {
"body-parser": "^1.20.2",
"cors": "^2.8.5",
"express": "^4.18.2",
"mongoose": "^8.0.3",
"multer": "^1.4.5-lts.1",
"uuid": "^9.0.1"
}
Example: Create the required files and add the following code:
Step 3: To start the backend run the following command.
node server.jsStep 4: Set up React frontend using the command.
npx create-react-app social_frontend
cd social_frontend
Step 5 : Installing the required packages:
npm i axios react-router-domFolder Structure(Frontend):
👁 frThe updated dependencies in package.json file of frontend will look lik:
"dependencies": {
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"axios": "^1.6.5",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.21.1",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
}
Example: Create the required files and the following code.
Step 6: Start the application by running the following command.
npm startOutput: