MERN Projects for Beginners: Create Five Social Web Apps Using MongoDB, Express.js, React, and Node
()
About this ebook
Learn how to use the MERN stack (MongoDB, Express.js, React, and Node) to build five fully functioning web apps for dating, video sharing, messaging, and social media. While creating these web apps, you’ll learn key development concepts including how to use React hooks, Redux, MongoDB, Express, Heroku, Firebase, Material UI, and Google authentication. By expanding your portfolio with the projects you create, you will be well equipped as front-end developer.
You will first create a dating site with a swiping feature and chat functionality. You will then build a video sharing app with videos displaying vertically. Next, you will learn to build an awesome messaging web app. Users will be able to chat in real time, as well as log in to their account using Google authentication. You will also create a photo sharing app and social media web apps with the ability to post images with captions and log in using email and password authentication.
Most MERN tutorials out there today cover basic web apps but it is capable of so much more – learn how to use this stack to its full potential and build projects that can be converted into full scaled start-ups with additional features.
What You'll Learn
- Work with React hooks and React router
- Examine powerful MongoDB services for easy to use and setup
- Create routes using Node and host on Heroku
- Study different authentication techniques
- Deploy all sites using simple Firebase hosting
- Use the powerful React ecosystem to add functionalities to your apps
Who This book Is For
Those who have just started their career in web development and have basic knowledge of the core web technologies: HTML, CSS, and JavaScript. Those with basic React development and feel ready to explore its capabilities further.
Related to MERN Projects for Beginners
Related ebooks
Foundation Gatsby Projects: Create Four Real Production Websites with Gatsby Rating: 0 out of 5 stars0 ratingsPractical Enterprise React: Become an Effective React Developer in Your Team Rating: 0 out of 5 stars0 ratingsWeb App Development and Real-Time Web Analytics with Python: Develop and Integrate Machine Learning Algorithms into Web Apps Rating: 0 out of 5 stars0 ratingsBuilding React Apps with Server-Side Rendering: Use React, Redux, and Next to Build Full Server-Side Rendering Applications Rating: 0 out of 5 stars0 ratingsLearn ASP.NET Core MVC - Be Ready Next Week Using Visual Studio 2017 Rating: 5 out of 5 stars5/5Practical Rust Web Projects: Building Cloud and Web-Based Applications Rating: 0 out of 5 stars0 ratingsAR and VR Using the WebXR API: Learn to Create Immersive Content with WebGL, Three.js, and A-Frame Rating: 0 out of 5 stars0 ratingsGame and Graphics Programming for iOS and Android with OpenGL ES 2.0 Rating: 0 out of 5 stars0 ratingsReact and React Native Rating: 0 out of 5 stars0 ratingsLearning RabbitMQ with C#: A magical tool for the IT world Rating: 0 out of 5 stars0 ratingsModern Web Development with Deno: Develop Modern JavaScript and TypeScript Code with Svelte, React, and GraphQL (English Edition) Rating: 0 out of 5 stars0 ratingsLearning Docker - Second Edition Rating: 0 out of 5 stars0 ratingsBuilding Scalable Apps with Redis and Node.js Rating: 0 out of 5 stars0 ratingsPro MERN Stack: Full Stack Web App Development with Mongo, Express, React, and Node Rating: 0 out of 5 stars0 ratingsEssential TypeScript 4: From Beginner to Pro Rating: 0 out of 5 stars0 ratingsModern Front-end Architecture: Optimize Your Front-end Development with Components, Storybook, and Mise en Place Philosophy Rating: 0 out of 5 stars0 ratingsPractical Svelte: Create Performant Applications with the Svelte Component Framework Rating: 0 out of 5 stars0 ratingsSpring Boot with React and AWS: Learn to Deploy a Full Stack Spring Boot React Application to AWS Rating: 0 out of 5 stars0 ratingsReact and Libraries: Your Complete Guide to the React Ecosystem Rating: 0 out of 5 stars0 ratingsSurviving the Whiteboard Interview: A Developer’s Guide to Using Soft Skills to Get Hired Rating: 5 out of 5 stars5/5Docs for Developers: An Engineer’s Field Guide to Technical Writing Rating: 0 out of 5 stars0 ratingsWebAssembly for Cloud: A Basic Guide for Wasm-Based Cloud Apps Rating: 0 out of 5 stars0 ratingsIrresistible APIs: Designing web APIs that developers will love Rating: 0 out of 5 stars0 ratingsDecoupled Django: Understand and Build Decoupled Django Architectures for JavaScript Front-ends Rating: 0 out of 5 stars0 ratingsThe Full Stack Developer: Your Essential Guide to the Everyday Skills Expected of a Modern Full Stack Web Developer Rating: 0 out of 5 stars0 ratingsApache Pulsar in Action Rating: 0 out of 5 stars0 ratingsBeginning Kubernetes on the Google Cloud Platform: A Guide to Automating Application Deployment, Scaling, and Management Rating: 0 out of 5 stars0 ratingsMastering Swift Rating: 0 out of 5 stars0 ratings
Internet & Web For You
More Porn - Faster!: 50 Tips & Tools for Faster and More Efficient Porn Browsing Rating: 3 out of 5 stars3/5Coding All-in-One For Dummies Rating: 4 out of 5 stars4/5Social Media Marketing For Dummies Rating: 5 out of 5 stars5/5The Digital Marketing Handbook: A Step-By-Step Guide to Creating Websites That Sell Rating: 5 out of 5 stars5/5Grokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5The Logo Brainstorm Book: A Comprehensive Guide for Exploring Design Directions Rating: 4 out of 5 stars4/5Coding For Dummies Rating: 5 out of 5 stars5/5Introduction to Internet Scams and Fraud: Credit Card Theft, Work-At-Home Scams and Lottery Scams Rating: 4 out of 5 stars4/5The $1,000,000 Web Designer Guide: A Practical Guide for Wealth and Freedom as an Online Freelancer Rating: 5 out of 5 stars5/5Python QuickStart Guide: The Simplified Beginner's Guide to Python Programming Using Hands-On Projects and Real-World Applications Rating: 0 out of 5 stars0 ratingsHacking : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Ethical Hacking Rating: 5 out of 5 stars5/5Wireless Hacking 101 Rating: 4 out of 5 stars4/5The Mega Box: The Ultimate Guide to the Best Free Resources on the Internet Rating: 4 out of 5 stars4/5Cybersecurity For Dummies Rating: 4 out of 5 stars4/5C++ Learn in 24 Hours Rating: 0 out of 5 stars0 ratingsRemote/WebCam Notarization : Basic Understanding Rating: 3 out of 5 stars3/5Print On Demand Profits Rating: 4 out of 5 stars4/5Mike Meyers' CompTIA Security+ Certification Guide, Third Edition (Exam SY0-601) Rating: 5 out of 5 stars5/5Podcasting For Dummies Rating: 4 out of 5 stars4/5How To Make Money Blogging: How I Replaced My Day-Job With My Blog and How You Can Start A Blog Today Rating: 4 out of 5 stars4/5How To Start A Profitable Authority Blog In Under One Hour Rating: 5 out of 5 stars5/5Six Figure Blogging Blueprint Rating: 5 out of 5 stars5/5Six Figure Blogging In 3 Months Rating: 4 out of 5 stars4/5The Beginner's Affiliate Marketing Blueprint Rating: 4 out of 5 stars4/5Stop Asking Questions: How to Lead High-Impact Interviews and Learn Anything from Anyone Rating: 5 out of 5 stars5/5Wordpress for Beginners: The Easy Step-by-Step Guide to Creating a Website with WordPress Rating: 5 out of 5 stars5/5Everybody Lies: Big Data, New Data, and What the Internet Can Tell Us About Who We Really Are Rating: 4 out of 5 stars4/5
Reviews for MERN Projects for Beginners
0 ratings0 reviews
Book preview
MERN Projects for Beginners - Nabendu Biswas
© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2021
N. BiswasMERN Projects for Beginnershttps://doi.org/10.1007/978-1-4842-7138-4_1
1. MERN Deployment Setup
Nabendu Biswas¹
(1)
Bhopal, India
Welcome to MERN Projects for Beginners, where you learn to build awesome web apps using the MERN (MongoDB, Express, React, Node.js) framework. This stack is in high demand in the startup sector because you can make a fully functional web app using it. A front-end engineer who knows HTML, CSS, and React can quickly learn Node.js and MongoDB and build a fully production-ready web app.
In this book, you learn how to host a back end using Node.js code in Heroku. The front-end site uses React code and Firebase hosting. It is also hosted through a cloud database called MongoDB Atlas. Most of the hosting setups are the same in the next five chapters, so it won’t be repeated in most chapters.
The MERN Stack at a Glance
Before installing Firebase, let’s discuss the basics of the technologies involved in the MERN stack.
MongoDB is an open source document based on the NoSQL database. It is different from traditional relational databases that store data in tables. It stores data in JSON-like documents. It is highly scalable and performance-oriented and thus suited for modern-day web apps.
React is the most popular open source JavaScript library for building a website’s or web app’s front end or user interface. It is developed and maintained by Facebook.
Node.js lets developers write server-side code using JavaScript. It integrates very well with React or Angular at the front end and with MongoDB for databases.
Express is a framework of Node.js, and through it, you can create API endpoints, which are the basis of any back-end server-side code.
Firebase Hosting Initial Setup
You need a Google account to work with Firebase. Go to https://firebase.google.com and click Go to console in the top-right corner. You must be logged in to your Google account to do so, as seen in Figure 1-1.
../images/512020_1_En_1_Chapter/512020_1_En_1_Fig1_HTML.jpgFigure 1-1
Firebase console caption
Click the Add project link on the page, as seen in Figure 1-2.
../images/512020_1_En_1_Chapter/512020_1_En_1_Fig2_HTML.jpgFigure 1-2
Add project
On this page, name the project dating-app-mern, and then click the Continue button, as seen in Figure 1-3. Note that this is just an installation instruction. You start building the app in the next chapter.
../images/512020_1_En_1_Chapter/512020_1_En_1_Fig3_HTML.jpgFigure 1-3
App name
On the next page, click the Create project button, as seen in Figure 1-4.
../images/512020_1_En_1_Chapter/512020_1_En_1_Fig4_HTML.jpgFigure 1-4
Create project
It takes some time to create the project, as seen in Figure 1-5.
../images/512020_1_En_1_Chapter/512020_1_En_1_Fig5_HTML.jpgFigure 1-5
Project created
MongoDB Setup
MongoDB is the database that you work with on the cloud. It is also known as MongoDB Atlas. This is easier to work with than setting up on a local machine. Go to www.mongodb.com and log in or create a new account.
Creating a New Project
After logging in, you see a screen similar to the one shown in Figure 1-6. Click the New Project button.
../images/512020_1_En_1_Chapter/512020_1_En_1_Fig6_HTML.jpgFigure 1-6
MongoDB new project
Name your project dating-app-mern, and then click the Next button, as seen in Figure 1-7.
../images/512020_1_En_1_Chapter/512020_1_En_1_Fig7_HTML.jpgFigure 1-7
Project name
On the next screen, click the Create Project button, as seen in Figure 1-8.
../images/512020_1_En_1_Chapter/512020_1_En_1_Fig8_HTML.jpgFigure 1-8
MongoDB Create Project
On the next screen, click the Build a Cluster button, as seen in Figure 1-9.
../images/512020_1_En_1_Chapter/512020_1_En_1_Fig9_HTML.jpgFigure 1-9
Build a Cluster
On the next screen, select the Free tier, as seen in Figure 1-10.
../images/512020_1_En_1_Chapter/512020_1_En_1_Fig10_HTML.jpgFigure 1-10
Free tier
On the next screen, you need to choose the AWS region in which to create the database. (I chose Mumbai because I live in India, and this gives me low latency.) Afterward, click the Create Cluster button, as seen in Figure 1-11.
../images/512020_1_En_1_Chapter/512020_1_En_1_Fig11_HTML.jpgFigure 1-11
Choose region
The next screen shows that the cluster has been created, which takes time. You can go back and create your first API endpoint, as seen in Figure 1-12.
../images/512020_1_En_1_Chapter/512020_1_En_1_Fig12_HTML.jpgFigure 1-12
Cluster created
Database User and Network Access
To create a user in MongoDB, click the Database Access tab and then the Add New Database User button, as seen in Figure 1-13.
../images/512020_1_En_1_Chapter/512020_1_En_1_Fig13_HTML.jpgFigure 1-13
Create database user
On the next screen, you need to enter a username and a password, as seen in Figure 1-14. You must remember both. Next, scroll down and click the Add User button.
../images/512020_1_En_1_Chapter/512020_1_En_1_Fig14_HTML.jpgFigure 1-14
Add user
Next, go to the Network Access tab and click the Add IP Address button, as seen in Figure 1-15.
../images/512020_1_En_1_Chapter/512020_1_En_1_Fig15_HTML.jpgFigure 1-15
Network access
In the popup window, click the ALLOW ACCESS FROM ANYWHERE button and then click the Confirm button, as seen in Figure 1-16.
../images/512020_1_En_1_Chapter/512020_1_En_1_Fig16_HTML.jpgFigure 1-16
Allow access
Next, return to the Cluster tab and click the CONNECT button, which opens the popup window shown in Figure 1-17. Click the Connect your application tab.
../images/512020_1_En_1_Chapter/512020_1_En_1_Fig17_HTML.jpgFigure 1-17
Connect your application
Copy the connection URL by clicking the Copy button, as seen in Figure 1-18.
../images/512020_1_En_1_Chapter/512020_1_En_1_Fig18_HTML.jpgFigure 1-18
Connection string
Deploying the Back End to Heroku
Once you complete the back-end code, go to www.heroku.com to deploy the back end. Log in to your Heroku account, click the New drop-down menu, and then click the Create new app button, as seen in Figure 1-19. You can also do this from the command line using the Heroku CLI, but that is not covered here.
../images/512020_1_En_1_Chapter/512020_1_En_1_Fig19_HTML.jpgFigure 1-19
Heroku login
Next, name the app and click the Create app button , as seen in Figure 1-20.
../images/512020_1_En_1_Chapter/512020_1_En_1_Fig20_HTML.jpgFigure 1-20
Heroku app name
The next screen shows all the commands to deploy your app, but you need the Heroku CLI. Click the link and follow the instructions to install it on your operating system, as seen in Figure 1-21.
../images/512020_1_En_1_Chapter/512020_1_En_1_Fig21_HTML.jpgFigure 1-21
Heroku instructions
Run the heroku login command in the backend folder. You are asked for permission to open the browser. This command asks you to press any key to open in the browser.
../images/512020_1_En_1_Chapter/512020_1_En_1_Fig22_HTML.jpgFigure 1-22.
Here, you can log in with your credentials, as seen in Figure 1-23.
../images/512020_1_En_1_Chapter/512020_1_En_1_Fig23_HTML.jpgFigure 1-23
Login credentials
After successfully logging in, you see the page shown in Figure 1-24, which you need to close.
../images/512020_1_En_1_Chapter/512020_1_En_1_Fig24_HTML.jpgFigure 1-24
Close popup
You need to push the code from your local machine to the Heroku repository. Now that you are logged in to your account, you can run the following command to connect to Heroku Git.
heroku git:remote -a dating-mern-backend
Next, let’s run the familiar git command to commit the