MongoDB

Fresh install nextjs following docs - And using the following for mongodb
auth.ts
import { betterAuth } from "better-auth";
import { mongodbAdapter } from "better-auth/adapters/mongodb";
import { client } from "@/db/index"; // Importing specifically from index

export const auth = betterAuth({
    database: mongodbAdapter(client)
});


my db instance
index.ts
import { MongoClient } from "mongodb";

const uri = "mongodb://localhost:27017";
const client = new MongoClient(uri);

export async function connectToDatabase() {
    if (!client.isConnected()) {
        await client.connect();
    }
    return client.db("testdb");
}

export { client };


"mongodb is not supported" when doing generate. "
Was this page helpful?