O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

MERN Quick Start Guide

Book Description

Build web applications with MongoDB, ExpressJS, React, and Node

About This Book
  • Build applications with the MERN stack
  • Work with each component of the MERN stack
  • Become confident with MERN and ready for more!
Who This Book Is For

The book is for JavaScript developers who want to get stated with the MERN Stack.

What You Will Learn
  • Get started with the MERN stack
  • Install Node.js and configure MongoDB
  • Build RESTful APIs with Express.js and Mongoose
  • Build real-time applications with Socket.IO
  • Manage synchronous and asynchronous data flows with Redux
  • Build web applications with React
In Detail

The MERN stack is a collection of great tools—MongoDB, Express.js, React, and Node—that provide a strong base for a developer to build easily maintainable web applications. With each of them a JavaScript or JavaScript-based technology, having a shared programming language means it takes less time to develop web applications.

This book focuses on providing key tasks that can help you get started, learn, understand, and build full-stack web applications. It walks you through the process of installing all the requirements and project setup to build client-side React web applications, managing synchronous and asynchronous data flows with Redux, and building real-time web applications with Socket.IO, RESTful APIs, and other concepts. This book gives you practical and clear hands-on experience so you can begin building a full-stack MERN web application.

Quick Start Guides are focused, shorter titles that provide a faster paced introduction to a technology. They are for people who don't need all the detail at this point in their learning curve. The presentation has been streamlined to concentrate on the things you really need to know.

Style and approach

This guide shows you how to use your JavaScript knowledge to build web applications that use the MERN stack in both client-side and in server-side environments.

Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Title Page
  2. Copyright and Credits
    1. MERN Quick Start Guide
  3. Packt Upsell
    1. Why subscribe?
    2. PacktPub.com
  4. Contributors
    1. About the author
    2. About the reviewer
    3. Packt is searching for authors like you
  5. Preface
    1. What this book covers
    2. To get the most out of this book
    3. What you need for this book 
      1. Download the example code files
      2. Download the color images
      3. Code in Action
      4. Conventions used
    4. Sections
      1. Getting ready
      2. How to do it...
      3. Let's test it...
      4. How it works...
      5. There's more...
      6. See also
    5. Get in touch
      1. Reviews
  6. Introduction to the MERN Stack
    1. Technical requirements
    2. Introduction
    3. The MVC architectural pattern
    4. Installing and configuring MongoDB
      1. Getting ready
      2. How to do it...
      3. There's more...
    5. Installing Node.js
      1. Getting ready
      2. How to do it...
    6. Installing npm packages
      1. Getting ready
      2. How to do it...
      3. How it works...
  7. Building a Web server with ExpressJS
    1. Technical requirements
    2. Introduction
    3. Routing in ExpressJS
      1. Getting ready
      2. How to do it...
      3. Route methods
      4. Route handlers
      5. Chainable route methods
      6. There's more...
    4. Modular route handlers
      1. Getting ready
      2. How to do it...
    5. Writing middleware functions
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Writing configurable middleware functions
      1. Getting ready
      2. How to do it...
      3. Let's test it...
      4. There's more...
    7. Writing router-level middleware functions
      1. Getting ready
      2. How to do it...
      3. There's more...
      4. How it works...
    8. Writing error-handler middleware functions
      1. Getting ready
      2. How to do it...
    9. Using ExpressJS' built-in middleware function for serving static assets
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    10. Parsing the HTTP request body
      1. Getting ready
      2. How to do it...
      3. How it works...
    11. Compressing HTTP responses
      1. Getting ready
      2. How to do it...
      3. How it works...
    12. Using an HTTP request logger
      1. Getting ready
      2. How to do it...
    13. Managing and creating virtual domains
      1. Getting ready
      2. How to do it...
      3. There's more...
    14. Securing an ExpressJS web application with Helmet
      1. Getting ready
      2. How to do it...
      3. How it works...
    15. Using template engines
      1. Getting ready
      2. How to do it...
    16. Debugging your ExpressJS web application
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
  8. Building a RESTful API
    1. Technical requirements
    2. Introduction
    3. CRUD operations using ExpressJS' route methods
      1. Getting ready
      2. How to do it...
      3. Let's test it...
      4. How it works...
    4. CRUD operations with Mongoose
      1. Getting ready
      2. How to do it...
      3. See also
    5. Using Mongoose query builders
      1. Getting ready
      2. How to do it...
      3. See also
    6. Defining document instance methods
      1. Getting ready
      2. How to do it...
      3. There's more...
      4. See also
    7. Defining static model methods
      1. Getting ready
      2. How to do it...
      3. There's more...
      4. See also
    8. Writing middleware functions for Mongoose
      1. Getting ready
      2. How to do it...
        1. Document middleware functions
        2. Query middleware functions
        3. Model middleware functions
      3. There's more...
      4. See also
    9. Writing custom validators for Mongoose's schemas
      1. Getting ready
      2. How to do it...
      3. See also
    10. Building a RESTful API to manage users with ExpressJS and Mongoose
      1. Getting ready
      2. How to do it...
      3. Let's test it...
      4. How it works...
      5. See also
  9. Real-Time Communication with Socket.IO and ExpressJS
    1. Technical requirements
    2. Introduction
    3. Understanding Node.js events
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    4. Understanding Socket.IO events
      1. The Socket.IO server events
      2. Socket.IO client events
      3. Getting ready
      4. How to do it...
      5. How it works...
    5. Working with Socket.IO namespaces
      1. Getting ready
      2. How to do it...
      3. Let's test it...
      4. How it works...
      5. There's more...
        1. io.Manager
    6. Defining and joining Socket.IO rooms
      1. Getting ready
      2. How to do it...
      3. There's more...
    7. Writing middleware for Socket.IO
      1. Getting ready
      2. How to do it...
      3. Let's test it...
    8. Integrating Socket.IO with ExpressJS
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    9. Using ExpressJS middleware in Socket.IO
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
  10. Managing State with Redux
    1. Technical requirements
    2. Introduction
    3. Defining actions and action creators
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Defining reducer functions
      1. Getting ready
      2. How to do it...
      3. Let's test it...
      4. How it works...
    5. Creating a Redux store
      1. Getting ready
      2. How to do it...
      3. Let's test it...
      4. There's more
    6. Binding action creators to the dispatch method
      1. Getting ready
      2. How to do it...
      3. Let's test it...
    7. Splitting and combining reducers
      1. Getting ready
      2. How to do it...
      3. Let's test it...
      4. How it works...
    8. Writing Redux store enhancers
      1. Getting ready
      2. How to do it...
      3. How it works...
    9. Time traveling with Redux
      1. Getting ready
      2. How to do it...
      3. Let's test it...
      4. There's more
    10. Understanding Redux middleware
      1. Getting ready
      2. How to do it...
      3. Let's test it...
      4. How it works...
    11. Dealing with asynchronous data flow
      1. Getting ready
      2. How to do it...
      3. Let's test it...
      4. How it works...
      5. There's more...
  11. Building Web Applications with React
    1. Technical requirements
    2. Introduction
    3. Understanding React elements and React components
      1. Getting ready
      2. How to do it...
      3. Let's test it...
    4. Composing components
      1. Getting ready
      2. How to do it...
      3. Let's test it...
      4. How it works...
      5. There's more...
    5. Stateful components and life cycle methods
      1. Getting ready
      2. How to do it...
      3. Let's test it...
    6. Working with React.PureComponent
      1. Getting ready
      2. How to do it...
      3. Let's test it...
      4. How it works...
    7. React event handlers
      1. Getting ready
      2. How to do it...
      3. Let's test it...
      4. How it works...
      5. There's more...
    8. Conditional rendering of components
      1. Getting ready
      2. How to do it...
      3. Let's test it...
      4. How it works...
    9. Rendering lists with React
      1. Getting ready
      2. How to do it...
      3. Let's test it...
      4. How it works...
    10. Working with forms and inputs in React
      1. Getting ready
      2. How to do it...
      3. Let's test it...
      4. How it works...
    11. Understanding refs and how to use them
      1. Getting ready
      2. How to do it...
      3. Let's test it...
      4. How it works...
    12. Understanding React portals
      1. Getting ready
      2. How to do it...
      3. Let's test it...
      4. How it works...
    13. Catching errors with error boundary components
      1. Getting ready
      2. How to do it...
      3. Let's test it...
    14. Type checking properties with PropTypes
      1. Getting ready
      2. How to do it...
      3. Let's test it...
      4. How it works...
      5. There's more...
  12. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think