Supabase

This guide discusses the concepts behind using Prisma ORM 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?

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 ORM.

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

Commonalities with other database providers

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

Specific considerations

If you'd like to use the available with Supabase, you will need to use the connection pooling connection string available via your with ?pgbouncer=true appended to the end of your DATABASE_URL environment variable:

.env
1# Connect to Supabase via connection pooling with Supavisor.
2DATABASE_URL="postgres://postgres.[your-supabase-project]:[password]@aws-0-eu-central-1.pooler.supabase.com:6543/postgres?pgbouncer=true"

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 Supavisor:

.env
1# Connect to Supabase via connection pooling with Supavisor.
2DATABASE_URL="postgres://postgres.[your-supabase-project]:[password]@aws-0-eu-central-1.pooler.supabase.com:6543/postgres?pgbouncer=true"
3
+# Direct connection to the database. Used for migrations.
+DIRECT_URL="postgres://postgres:[password]@db.[your-supabase-project].supabase.co:5432/postgres"

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

schema.prisma
1datasource db {
2 provider = "postgresql"
3 url = env("DATABASE_URL")
+ directUrl = env("DIRECT_URL")
5}

More information about the directUrl field can be found here.

We strongly recommend using connection pooling with Supavisor 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 your 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 .

If you're running into issues integrating with Supabase, check out these or for more help.