Intro
Supabase is a cloud provider offering multiple services. One of its core services is PostgreSQL databases. Supabase’s free tier is far more generous than Render’s. However, if the database is not accessed for a week it will hibernate the database and you will need to manually restart it from the Supabase dashboard.
π Registration
To set up your database do the following:
- Go to their website at https://supabase.com/ and click Start your project
- Sign up using GitHub
- On the resulting page, it will ask you to create your first project.
- Set the name of the database to
your-project-name
- On the database password part click Generate a password. Make sure you copy and store this value in a secure place, preferably a password manager
- As a region pick
East US (Northern Virginia)
if you are using Netlify for your backend, as this is the closest region to it. If you are using other backend providers you should check which region they are in and select the closest one to them here. - Finally, click Create a new project
π Connecting to your database
Once your project is ready go to the project’s dashboard. Then on the left-hand side click Settings (it’s the icon with a cogwheel) and then go to the Database tab.
- Scroll down to the Connection Pooling part
- Select Session as the Pool Mode
- Copy the Connection String. It will look like this:
postgres://postgres.fjdshfkjsfhkuse:[YOUR-PASSWORD]@aws-0-eu-west-2.pooler.supabase.com:6543/postgres
Replace the [YOUR-PASSWORD]
part with the one you set up during registration. IF you have forgotten that, there will be a “Reset database password” button on this website to set it up again.
Make sure to click Save as well, if you need to change the Pool Mode setting.
ποΈ Accessing the database
Gather the following details:
- The server. This will be something like
aws-0-eu-west-2.pooler.supabase.com
for Supabase. - The username. This will be something like
postgres.fjdshfkjsfhkuse
. - The database name. This will be
postgres
. - Your password. This is what you have entered when creating the database.
Now connect to your database server from the command line like this:
psql -h server_from_above -U username_from_above database_name_from_above