Appearance
MongoDB & Prisma Setup
NextSaasPilot uses MongoDB as its primary database, managed via the Prisma ORM. This guide will help you configure your database connection and Prisma for local development or production.

1. Configure Your MongoDB Connection (.env)
You need to set your MongoDB connection string in the .env
file at the root of your project.
txt
# Example for MongoDB Atlas
DATABASE_URL="mongodb+srv://<user>:<password>@<cluster-url>/<database-name>?retryWrites=true&w=majority"
# Example for a local MongoDB instance
# DATABASE_URL="mongodb://localhost:27017/<database-name>"
- Replace
<user>, <password>, <cluster-url>
, and<database-name>
with your actual MongoDB Atlas credentials and database name. - If using a local MongoDB instance, adjust the URL accordingly.
2. Prisma Commands (package.json)
json
{
"scripts": {
"db:studio": "prisma studio",
"db:push": "prisma db push",
"db:generate": "prisma generate"
}
}
Here’s what each Prisma command does:
npm run db:generate
: Generates the Prisma Client based on your currentschema.prisma
file. Run this command whenever you make changes to your Prisma schema to update the generated client code used in your app.npm run db:push
: Applies the current state of your Prisma schema to your database. This updates your database structure (tables, fields, etc.) to match your schema without running migrations.npm run db:studio
: Launches Prisma Studio, a web-based GUI for viewing and editing the data in your database. This is useful for inspecting tables, making quick changes, or debugging.
Typical Workflow
- Define Models: Modify your
prisma/schema.prisma
file. - Sync Schema: Run
npm run db:push
to update your MongoDB schema. - Develop: Start your application (
npm run dev
).