MongoDB
Fresh install nextjs following docs - And using the following for mongodb
auth.ts
my db instance
index.ts
"mongodb is not supported" when doing generate. "
auth.ts
my db instance
index.ts
"mongodb is not supported" when doing generate. "
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)
});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 };