Supabase provides a CLI so that you can develop your application locally, with the ability to deploy your application to the Supabase platform.
Before we begin, make sure you have these installed on your local machine:
Supabase CLI login
This is a one-time operation. After you have logged in the CLI will have permissions to manage your Supabase projects.
Initialize your project
Let's create a new folder on your local machine:
# create your project folder
# move into the new folder
# start a new git repository
These commands will create an empty folder for your project and start a new git repository.
Let's initialize Supabase inside the folder that you created:
This command will create a
supabase folder which holds all the configuration for developing your project locally.
Once all of the Supabase services are running, you'll see an output that contains your local Supabase credentials.
You can use the stop command at any time to stop all services.
Accessing Services Directly
- API Gateway
# Default URL:
# Default URL:
All of the services are accessible through the API Gateway Kong).
If you are accessing these services without the client libraries, you may need to pass the client keys as an
You can learn more about these JWT headers in our Resources.
curl 'http://localhost:54321/rest/v1/' \
-H "apikey: <anon key>" \
-H "Authorization: Bearer <anon key>"
http://localhost:54321/rest/v1/ # REST (PostgREST)
http://localhost:54321/realtime/v1/ # Realtime
http://localhost:54321/storage/v1/ # Storage
http://localhost:54321/auth/v1/ # Auth (GoTrue)
Database changes are managed through "migrations". Database migrations are a common way of tracking changes to your database over time.
Making database changes
For this guide, let's create a table called
employees, using the "Supabase Studio" link provided.
If you're familiar with databases, you can also execute any SQL using the
DB URL shown by
Open the Studio, navigate to the "SQL Editor" section, and run the following SQL command:
create table employees (
id integer primary key generated always as identity,
Now we have the
employees table in the local database, but how do we incorporate this into migrations? The CLI automatically detects changes by running the commit command:
supabase db commit create_employees
This creates a new migration named
supabase/migrations/<timestamp>_create_employees.sql, representing any changes we've made to the local database since
Adding sample data
Let's add some sample data into the table. We can use the seed script in
supabase/seed.sql (which gets created when you run
-- in supabase/seed.sql
insert into public.employees (name)
Now run the following to rerun the migration scripts and the seed script:
supabase db reset
If you look again within Studio, you should now see the contents of
Resetting database changes
If you run any SQL on the local database that you want to revert, you can use the
-- run on local database to make a change
alter table employees
add department text default 'Hooli';
To revert this change we can run:
supabase db reset
And the local database will be reset.
Now that you've developed an application locally, head over to app.supabase.com and create a project where we can deploy the changes.
Linking your project
There are a few commands required to link your project. We are in the process of consolidating these commands into a single command. Bear with us!
# Use "supabase link --project-ref your-project-ref" to link your project in one step.
supabase db remote set 'postgresql://postgres:<your_password>@db.<your_project_ref>.supabase.co:5432/postgres'
# Use the connection string from your Supabase project here.
supabase db remote commit
# capture any changes that you have made to your database before setting up the CLI
You'll notice that
supabase/migrations is now populated with a migration in
This migration captures any changes required for your local database to match the schema of your remote Supabase project.
Deploying Database changes
You can deploy any local database migrations using
supabase db push
Deploying Edge Functions
You can deploy any Edge Functions using
supabase functions deploy <function_name>
The local development environment is not as feature-complete as the Platform. Here are some of the differences:
- The Storage interface is coming soon.
- The Functions interface is coming soon.
- Logs are not supported through the interface (however you can accesss them via the docker containers).
- You cannot update your project settings via the Dashboard - this can be done using the CLI instead.