How do I get NextAuth's MongoDB Adaptor to use a specific database name when using database?

Viewed 18

I'm following this short guide on how to use the MongoDB Adaptor with NextAuth.js. It sort of works. After I install it like so:

import clientPromise from "../../../lib/mongodb"

export const authOptions: NextAuthOptions = {
  adapter: MongoDBAdapter(clientPromise),
  ...
}

I am able to see user data in MongoDB Atlas! Hurray!

enter image description here

enter image description here

But as you can see, the name of the database is called "test". :(

Instead, I would like it to use the database I have configured for it. (That database also has the rest of my application's data.)

My .env.local

MONGODB_URI=mongodb://localhost:27117
DB_NAME=my-app-db

My question is, how do I get the MongoDB Adaptor of NextAuth.js to use a specific database name?

0 Answers
Related