# How to use Supabase as your PostgreSQL hosting

> Learn how to use Supabase as your PostgreSQL hosting, grabbing the connection string for your DATABASE_URL and using its pgbouncer pooler with Prisma.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2022-06-23 | Topics: [Database](https://flaviocopes.com/tags/database/) | Canonical: https://flaviocopes.com/postgresql-supabase-setup/

I recently found out you can use Supabase as your [PostgreSQL](https://flaviocopes.com/postgres-introduction/) hosting. 

Supabase is a very interesting project. It’s not “just a database hosting” but it’s *also* one, so you can use it as that. It’s an app development platform built on top of PostgreSQL, and they offer a free [connection pooler](https://supabase.com/docs/guides/database/connecting-to-postgres#connection-pool), which helps [not exhausting the database connection limit with Prisma](https://www.prisma.io/docs/guides/performance-and-optimization/connection-management#pgbouncer).

They allow up to 2 projects in the free account, so it’s worth trying it. 

You can also work on a new project, then delete the old ones once you’re done.

Supabase markets itself as a [Firebase](https://firebase.google.com) alternative, and in addition to the database you have authentication, subscriptions, and a lot more you can explore later on.

> NOTE: Supabase can also be [self hosted](https://supabase.com/docs/guides/hosting/docker), so your 2 projects limit will disappear, at the expense of having to manage your own infrastructure

To set it up, first login with [GitHub](https://flaviocopes.com/github/) on [supabase.com](http://supabase.com)

Create a new project

![Screen Shot 2022-06-23 at 09.49.46.jpg](https://flaviocopes.com/images/postgresql-supabase-setup/Screen_Shot_2022-06-23_at_09.49.46.jpg)

![Screen Shot 2022-06-23 at 09.50.31.jpg](https://flaviocopes.com/images/postgresql-supabase-setup/Screen_Shot_2022-06-23_at_09.50.31.jpg)

Then go into Settings → Database, scroll down and you’ll find the direct connection string to the database (click URI)

![Screen Shot 2022-06-23 at 10.01.23.jpg](https://flaviocopes.com/images/postgresql-supabase-setup/Screen_Shot_2022-06-23_at_10.01.23.jpg)

That’s what you will need to put in your `.env` file for the `DATABASE_URL` variable. 

Remember to fill [YOUR-PASSWORD] with the password you set for the project when you created it on Supabase.

If you're ever unsure about the parts of a Postgres connection string, I built a free [connection string builder](https://flaviocopes.com/tools/connection-string/) that builds and parses them for you.

If you use [Prisma](https://flaviocopes.com/prisma/) now you can run `npx prisma migrate dev` to create the tables from the Prisma schema.

This would work already to connect to the database, but since Supabase offers a connection pooler, which helps us not exhaust the connections we can make to the database, why not use it?

If you use [Prisma](https://flaviocopes.com/prisma/): the connection pool does not work when using `npx prisma migrate dev`, for that command you must use the direct database connection string as shown above. So remember to swap the `DATABASE_URL` value in case you need it.

Below, you’ll see the connection pooling connection string:

![Screen Shot 2022-06-23 at 10.02.53.jpg](https://flaviocopes.com/images/postgresql-supabase-setup/Screen_Shot_2022-06-23_at_10.02.53.jpg)

When you copy that to your .env file, add `?pgbouncer=true` at the end [as explained here](https://www.prisma.io/docs/guides/performance-and-optimization/connection-management/configure-pg-bouncer#add-pgbouncer-to-the-connection-url).
