You don't have to use MongoDB, but you'll need a database to save users who log in.


  • Create a new project and deploy a cluster on MongoDB Atlas

    Run a local database for your dev setup so you can work offline and it's faster
  • In your project on MongoDB Altas, click [Network Access] then [+ Add IP Address]. Enter in [Access List Entry]. This allows connections from your computer and your production deployment(s) (Vercel for instance).
  • If you haven't done it yet, rename .env.example to .env.local. Then add your connection string to MONGODB_URI in .env.local.

Mongoose (optional)

Mongoose makes it easier to deal with MongoDB and has some cool features.
Models are defined in the folder /models. Add any new models there.
The plugin toJSON is added to all models to remove the _id and __v (easier on front-end).
Also if you add private: trueto any field it will be removed from the response. I.e. make email private so it's not sent to the front-end.