Using Prisma with Supabase

This guide discusses the concepts behind using Prisma and Supabase, explains the commonalities and differences between Supabase and other database providers, and leads you through the process for configuring your application to integrate with Supabase.

What is Supabase?

Supabase is a PostgreSQL hosting service and open source Firebase alternative providing all the backend features you need to build a product. Unlike Firebase, Supabase is backed by PostgreSQL which can be accessed directly using Prisma.

To learn more about Supabase, you can check out their architecture here and features here

Commonalities with other database providers

Many aspects of using Prisma with Supabase are just like using Prisma with any other relational database. You can still:

Specific considerations

If you'd like to use the connection pooling feature available with Supabase, you will need to add pgbouncer=true to the end of the DATABASE_URL environment variable used in the datasource.url property:

1# Connect to Supabase with PgBouncer.

If you would like to use the Prisma CLI in order to perform other actions on your database (e.g. migrations) you will need to add a DIRECT_URL environment variable to use in the datasource.directUrl property so that the CLI can bypass PgBouncer:

1# Connect to Supabase with PgBouncer.
+# Direct connection to the database. Used for migrations.

You can then update your schema.prisma to use the new direct URL:

1datasource db {
2 provider = "postgresql"
3 url = env("DATABASE_URL")
+ directUrl = env("DIRECT_URL")

More information about the directUrl field can be found here.

We strongly recommend using pgbouncer in addition to DIRECT_URL. You will gain the great developer experience of the Prisma CLI while also allowing for connections to be pooled regardless of deployment strategy. While this is not strictly necessary for every app, serverless solutions will inevitably require connection pooling.

Getting started with Supabase

If you're interested in learning more, Supabase has a great guide for connecting a database provided by Supabase to your Prisma project available here.

If you're running into issues integrating with Supabase, check out these specific troubleshooting tips or Prisma's GitHub Discussions for more help.

Edit this page on GitHub