Skip to main content

Database Setup

This document provides an overview of setting up the database for your project. We'll cover the necessary steps for both MongoDB (used with NextAuth) and Supabase.

MongoDB Setup

When using NextAuth, MongoDB is used as the database. Follow these steps to set up MongoDB:

Setup

  1. Create a new project and deploy a cluster on MongoDB Atlas:

    • Go to MongoDB Atlas and create a new project.
    • Deploy a new cluster.
  2. Run a local database for your dev setup:

    • Running a local instance of MongoDB can help you work offline and speed up development.
  3. Allow connections from your computer and production deployment(s):

    • In your MongoDB Atlas project, click [Network Access] then [+ Add IP Address].
    • Enter 0.0.0.0/0 in [Access List Entry]. This allows connections from anywhere.
  4. Add your connection string to .env.local:

    • Rename .env.example to .env.local.
    • Add your MongoDB connection string to MONGODB_URI in .env.local.

Mongoose (Optional)

Mongoose makes it easier to deal with MongoDB and has some cool features.

  • Models:
    • Models are defined in the folder /models. Add any new models there.