0
0
Supabasecloud~30 mins

Why Postgres powers Supabase - See It in Action

Choose your learning style9 modes available
Why Postgres powers Supabase
📖 Scenario: You are learning how Supabase uses Postgres as its database engine. Supabase is a platform that helps developers build apps quickly by providing a ready-to-use backend powered by Postgres.Understanding how Postgres works inside Supabase will help you see why it is a strong choice for cloud databases.
🎯 Goal: Build a simple Supabase project setup that connects to a Postgres database and creates a table to store user profiles.This will show how Postgres powers the data storage in Supabase.
📋 What You'll Learn
Create a Supabase client connected to a Postgres database
Define a configuration variable for the database schema
Write a query to create a table called profiles with columns id, username, and email
Add the final Supabase client call to execute the table creation
💡 Why This Matters
🌍 Real World
Supabase uses Postgres to store and manage app data reliably and scalably in the cloud.
💼 Career
Understanding how to connect and configure Postgres in Supabase is essential for backend cloud developers and database administrators.
Progress0 / 4 steps
1
Create Supabase client connection
Create a variable called supabaseUrl with the value "https://xyzcompany.supabase.co" and a variable called supabaseKey with the value "public-anonymous-key". Then create a Supabase client called supabase using createClient(supabaseUrl, supabaseKey).
Supabase
Need a hint?

Use createClient from @supabase/supabase-js with the URL and key.

2
Define database schema configuration
Add a constant called schema and set it to the string "public" to specify the Postgres schema to use.
Supabase
Need a hint?

Use a constant named schema with the value "public".

3
Write SQL query to create profiles table
Create a constant called createTableQuery and assign it a string with the SQL command to create a table named profiles with columns: id as uuid primary key, username as text not null, and email as text unique.
Supabase
Need a hint?

Write the SQL command as a template string assigned to createTableQuery.

4
Execute the table creation query
Use await supabase.rpc with the function name sql and pass an object with query: createTableQuery to run the SQL command. Assign the result to a constant called result.
Supabase
Need a hint?

Use await supabase.rpc('sql', { query: createTableQuery }) to run the SQL.