#MongoDB connection not using Vercel
1 messages · Page 1 of 1 (latest)
Hi @shy sparrow. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
To connect your local project with MongoDB, you can use the following connection string as an example:
datasource db {
provider = "mongodb"
url = "mongodb://USERNAME:PASSWORD@HOST/DATABASE?authSource=admin&retryWrites=true&w=majority"
}
Replace USERNAME, PASSWORD, HOST, and DATABASE with your MongoDB credentials and database details.
Also, since MongoDB is currently in preview, you need to specify the previewFeatures on your generator block:
generator client {
provider = "prisma-client-js"
previewFeatures = ["mongodb"]
}
Please note that this information is extracted from the Vercel template for a fullstack Prisma Next.js blog (https://vercel.com/templates/next.js/fullstack-prisma-nextjs-blog), and it assumes you are using Prisma as your database client. If you are using a different method to connect to MongoDB, the process might be different.