Does Supabase Work With Prisma?

Fully CompatibleLast verified: 2026-02-26

Supabase and Prisma work excellently together, with Prisma providing type-safe database access to Supabase's PostgreSQL backend.

Quick Facts

Compatibility
full
Setup Difficulty
Easy
Official Integration
No — community maintained
Confidence
high
Minimum Versions
Prisma: 4.0.0

How Supabase Works With Prisma

Supabase provides a managed PostgreSQL database that Prisma can connect to directly via standard connection strings. You define your schema in Prisma's schema.prisma file, and Prisma generates migrations and type-safe client code. The connection is straightforward: Supabase gives you a DATABASE_URL, you paste it into your .env file, and Prisma handles the rest. This combination is particularly powerful because Supabase's real-time subscriptions work on the underlying database, so your Prisma-managed data automatically streams to clients via PostgreSQL's LISTEN/NOTIFY. You get the best of both worlds: type-safe queries from Prisma and real-time capabilities from Supabase's abstraction layer. The only architectural consideration is that Supabase's auth system is separate from Prisma—you'll use Supabase's auth client for login/signup, then use Prisma with the authenticated user's context for database operations.

Best Use Cases

Building real-time collaborative applications where Prisma manages the data model and Supabase's real-time API notifies clients of changes
Full-stack Next.js/Nuxt applications using Prisma for type safety and Supabase's managed auth for user management
SaaS platforms leveraging Supabase's row-level security (RLS) policies with Prisma's type-safe queries
Multi-tenant applications using Prisma's schema with Supabase's built-in PostgreSQL features like JSONB and arrays

Quick Setup

bash
npm install @prisma/client && npx prisma init
typescript
// schema.prisma
generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model User {
  id    Int     @id @default(autoincrement())
  email String  @unique
  name  String?
  posts Post[]
}

model Post {
  id    Int     @id @default(autoincrement())
  title String
  authorId Int
  author User @relation(fields: [authorId], references: [id])
}

// pages/api/posts.ts
import { PrismaClient } from '@prisma/client';

const prisma = new PrismaClient();

export default async function handler(req, res) {
  const posts = await prisma.post.findMany({
    include: { author: true }
  });
  res.json(posts);
}

// .env.local
DATABASE_URL="postgresql://user:password@db.supabase.co:5432/postgres"

Known Issues & Gotchas

warning

Supabase's Row-Level Security (RLS) policies bypass Prisma and operate at the database level, so Prisma won't enforce them in development

Fix: Test RLS policies directly against the database or use Supabase's API client for authenticated requests in production scenarios

warning

Prisma's migration tool can conflict with Supabase's schema management if you're also using Supabase's UI to modify tables

Fix: Establish a single source of truth—either manage schema entirely through Prisma migrations or sync Supabase changes back to your schema.prisma file

warning

Connection pooling: Prisma's default connection handling can exhaust Supabase's connection limits on serverless deployments

Fix: Use PgBouncer (Supabase supports this) or enable Prisma's connection pooling with appropriate pool size settings

info

Real-time subscriptions in Supabase use a separate WebSocket connection and won't automatically track Prisma mutations

Fix: Use Supabase's realtime client alongside Prisma, or implement webhook triggers to notify real-time subscribers when Prisma makes changes

Alternatives

  • Supabase + Drizzle ORM: Lighter-weight ORM with similar type safety but more control over SQL generation
  • Firebase + Firestore with native SDKs: Fully managed but lacks PostgreSQL's advanced features and relational queries
  • PlanetScale (MySQL) + Prisma: MySQL-based alternative for developers preferring that database system

Resources

Related Compatibility Guides

Explore more compatibility guides