Boilerplate app for full-stack MERN app with Create React App client tool chain. Includes React, JWT authentication, Mongoose/MongoDB, Apollo Server/Client, and ExpressJS.
-
Add a
.envfile toserverdirectory to run locally. Useserver/.env.exampleas a template. -
npm startscript: Production startup. Only runs backend server. -
npm run developscript: Usesconcurrentlyto run the back-end withnodemonand launches thecreate-react-appdevelopment server for front-end development.concurrentlyruns these within the same terminal. Logging is tagged with[server]or[client]. -
npm run clientscript: Launches thecreate-react-appdevelopment server for the client only. Will not start back-end. -
npm run serverscript: Starts the back-end server withnodemonfor easy development without launching the client. -
The
npm installscript: Installs all dependencies for root as wells asclientandserver. -
The
npm run buildscript: Runscreate-react-appbuild script to create client bundles and assets.
-
Requires a MongoDB server. MongoDB Atlas is a fairly easy choice for this requirement. Create an Atlas account and setup a database.
-
Add the following values to the Heroku config for the app:
SECRET- used for signing and verifying tokensTOKEN_EXP- duration before token expires in milliseconds or a string describing a time span. (zeit/ms)MONGODB_URI- used for connecting to MongoDB service
-
Push your code to GitHub
-
Connect your Heroku app with GitHub or push code directly to Heroku. (See Deploying Node.js Apps on Heroku)
This project uses apollo-server-express v 3.x which means GraphQL Playground (deprecated) is not included. Instead, Apollo Server 3 uses Apollo Studio as a development tool for building your api. If you would like to use GraphQL Playground, refer to this guide to enable the tool.
The client for this project is built with the create-react-app tool chain. The README file generated by create-react-app has been preserved. See client/README.md for details about the tools.