Skip to content

PostgreSQL

By default, NextSaasPilot uses MongoDB as its database. However, if you prefer PostgreSQL, you can easily switch to it and manage your database with Prisma. This guide explains how to use PostgreSQL with NextSaasPilot.

Quick Start with PostgreSQL Branch

NextSaasPilot provides a dedicated PostgreSQL branch for quick setup. You can checkout this branch to get started with PostgreSQL immediately

1. Update Prisma Schema (prisma/schema.prisma)

Edit your prisma/schema.prisma file so that the datasource provider is set to postgresql. Make sure your models are using types and settings that work well with PostgreSQL.

prisma
generator client {
  provider = "prisma-client"
  output   = "../generated/prisma"
}

datasource db {
  provider = "postgresql"
}

model User {
  id            String    @id @default(uuid())
  name          String
  email         String    @unique
  image         String?
  createdAt     DateTime  @default(now())
  updatedAt     DateTime  @updatedAt

  @@map("users")
}

2. Configure Your MongoDB Connection (.env)

  • Update the DATABASE_URL in your .env file to use your PostgreSQL connection string.

  • Replace placeholders with your actual PostgreSQL connection details.

txt
# Example PostgreSQL connection string
DATABASE_URL="postgresql://[USER]:[PASSWORD]@[HOST]:[PORT]/[DATABASE]"

Built with SaasPilot