Docs·UnderPeaks

Connecting Your Database · MongoDB

MongoDB

Create a MongoDB database

You can use MongoDB Atlas (cloud) or run MongoDB locally.

  1. Sign in at cloud.mongodb.com
  2. Create a new project and cluster (free M0 tier is fine for development)
  3. Under Database Access, create a user with read/write permissions
  4. Under Network Access, allow your IP address
  5. Click Connect → Drivers and copy the connection string

Set environment variables

NEXT_PUBLIC_DB_TYPE=mongodb
NEXT_DB_MONGO_URI=mongodb+srv://user:password@cluster.mongodb.net/underpeaks?retryWrites=true&w=majority
NEXT_DB_MONGO_DB_NAME=underpeaks

Connection string format

mongodb+srv://USER:PASSWORD@CLUSTER.mongodb.net/DATABASE_NAME

Replace USER, PASSWORD, CLUSTER, and DATABASE_NAME with your values.

Special characters in your password must be URL-encoded. For example, @ becomes %40.