Supabase CLI: Install It and Learn the Commands You Will Use

The Supabase CLI is a command line program that runs a copy of Supabase on your own computer and moves database changes to your live project. Install it with Homebrew, Scoop or npm, run supabase init and supabase start, then supabase link and supabase db push to send migrations to the hosted project.

Ways to install the Supabase CLI
SystemCommand
macOS or Linux (Homebrew)brew install supabase/tap/supabase
Windows (Scoop)scoop bucket add supabase https://github.com/supabase/scoop-bucket.git, then scoop install supabase
Any project (npm)npm install supabase --save-dev, then run npx supabase
Linux packages.apk, .deb or .rpm from the releases page

Updated

Type part of a command or a word like types, or pick a group, to narrow the table below. Every row is a command from the official CLI reference with a short note on when a site owner reaches for it.

Command finder

Search commands. Group: All, Setup, Local stack, Database, Types, Edge Functions

16 commands shown

CommandWhat it does
supabase loginSigns the CLI in to your Supabase account in the browser, or with --token.
supabase initCreates the supabase folder and config file in the current project.
supabase link --project-ref <project-ref>Connects this folder to a hosted project by its reference ID.
supabase startBoots the local stack in containers and prints the local URLs and keys.
supabase stopShuts the local stack down. Add --no-backup to discard local data.
supabase statusShows the local URLs and keys again. Add -o env to print them as environment variables.
supabase migration new <name>Makes an empty, timestamped SQL file in supabase/migrations for your change.
supabase db resetRebuilds the local database from the migrations and runs the seed file.
supabase db pushApplies new local migrations to the linked database. Try --dry-run first.
supabase db pullWrites the remote schema into a new migration file. Needs a running Docker daemon.
supabase db diff -f <name>Compares schemas and saves the difference as a migration with -f.
supabase gen types --lang typescript --linked > database.types.tsWrites TypeScript types for your tables. Use --local for the local database.
supabase functions new <name>Creates a new Edge Function folder with starter code.
supabase functions serveRuns your Edge Functions locally while you test.
supabase functions deploy <name>Uploads an Edge Function to the hosted project.
supabase secrets set NAME=VALUEStores a secret, such as a payment key, for your hosted Edge Functions.

A first session from start to finish

Run these in your project folder. Replace the reference ID with the one in your project's settings.

Local stack to hosted project

The order matters: create the migration, check it locally with a reset, then push it.

npx supabase init
npx supabase start
npx supabase migration new add_orders_table
# write your SQL in the new file under supabase/migrations
npx supabase db reset
npx supabase login
npx supabase link --project-ref abcdefghijklmnopqrst
npx supabase db push --dry-run
npx supabase db push
npx supabase gen types --lang typescript --linked > database.types.ts

Why use migrations instead of clicking in the dashboard

A migration is a numbered SQL file that records one change to your database. Keeping changes in files means you can test them locally, review them, and replay them on a fresh project in the same order.

Dashboard edits still happen. When they do, supabase db diff or supabase db pull turns the difference into a migration so your files catch up.

How it works

  1. Install the CLI and a container runtime such as Docker Desktop, because the local stack runs in containers.
  2. Run supabase init in your project folder to create the supabase folder with its config file.
  3. Run supabase start to boot the local stack, then open Studio, the database dashboard, at http://localhost:54323.
  4. Run supabase login and supabase link --project-ref with your project's reference ID to connect the hosted project.
  5. Write changes as migrations, test them locally, then run supabase db push to apply them to the hosted database.

Tips

Frequently asked questions

Do I need Docker for the Supabase CLI?

For the local stack, yes, or another container runtime. The guide names OrbStack, Rancher Desktop, Podman and colima as alternatives and mentions an experimental native runtime for Linux and Apple silicon Macs.

Can I install the Supabase CLI globally with npm?

The official guide says the npm package adds the CLI to a single project rather than a global command. Use Homebrew or Scoop for a system-wide install.

What is the difference between db push and db pull?

db push sends your local migration files to a database. db pull reads the schema of a remote database and writes it into a new migration file, which is handy when changes were made in the dashboard.

How do I generate TypeScript types?

Run supabase gen types --lang typescript with --local for the local database or --linked for the hosted one, and redirect the output into a file in your project.

How do I deploy an Edge Function?

Create one with supabase functions new and a name, then run supabase functions deploy with that name. Set its secrets with supabase secrets set NAME=VALUE.

Related: Supabase Auth guide, Supabase pricing, Supabase MCP server, Supabase vs Firebase.

Start for free or see all free tools. We.Inc is free to start, with no card needed. AI building is on paid plans from $20 a month.

More in Guides

We.Inc is an AI-powered website builder you can resell under your own brand. Launch a branded client dashboard, bill on Stripe Connect, and deliver AI-generated websites in minutes. White-label plans start at $99 a month for 25 client sites, with a 7-day free trial and no per-site fees.

Product

Who It's For

Features

Resources

Company

View Sitemap