Skip to content

How to use Supabase as your PostgreSQL hosting

New Course Coming Soon:

Get Really Good at Git

I recently found out you can use Supabase as your PostgreSQL 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, which helps not exhausting the database connection limit with Prisma.

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 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, 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 on

Create a new project

Screen Shot 2022-06-23 at 09.49.46.jpg

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

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

When you copy that to your .env file, add ?pgbouncer=true at the end as explained here.

Are you intimidated by Git? Can’t figure out merge vs rebase? Are you afraid of screwing up something any time you have to do something in Git? Do you rely on ChatGPT or random people’s answer on StackOverflow to fix your problems? Your coworkers are tired of explaining Git to you all the time? Git is something we all need to use, but few of us really master it. I created this course to improve your Git (and GitHub) knowledge at a radical level. A course that helps you feel less frustrated with Git. Launching May 21, 2024. Join the waiting list!
→ Read my SQL Tutorial on The Valley of Code

Here is how can I help you: