You can install the Supabase CLI using several package managers.
macOS (Homebrew):
brew install supabase/tap/supabase
npm (cross-platform):
npm install -g supabase
Windows (Scoop):
scoop bucket add supabase https://github.com/supabase/scoop-bucket.git
scoop install supabase
Verify the installation:
supabase --version
To authenticate the CLI with your Supabase account, run:
supabase login
This opens a browser window where you can generate an access token. Paste it back into the terminal when prompted. Your token is saved locally so you only need to do this once.
To confirm you're logged in:
supabase projects list
This returns a list of all projects under your account, along with their project refs — which you'll need in the next step.
Once logged in, navigate to your local project directory and run:
supabase link --project-ref <your-project-ref>
Finding your project ref:
Your project ref is the unique ID in your Supabase dashboard URL:
https://supabase.com/dashboard/project/<your-project-ref>
You can also find it under Project Settings → General.
Example:
supabase link --project-ref abcdefghijklmnopqrst
You'll be prompted for your database password. You can also pass it directly:
supabase link --project-ref abcdefghijklmnopqrst --password your-db-password
Once linked, the project ref is saved in .supabase/config.toml inside your project directory.
With your project linked, you can now run commands that interact with your remote Supabase project:
| Command | Description |
|---|---|
supabase db pull | Pull the remote database schema to local migrations |
supabase db push | Push local migrations to the remote database |
supabase db diff | Diff local vs remote schema |
supabase functions deploy | Deploy Edge Functions to your project |
supabase gen types typescript | Generate TypeScript types from your database schema |
If you haven't already, you can initialize Supabase in your local project directory:
supabase init
This creates a supabase/ folder with a config.toml and a migrations/ directory. This is where your local schema migrations and seed files live.
Here's a typical day-to-day workflow using the CLI:
# 1. Log in (first time only)
supabase login
# 2. Initialize local project (first time only)
supabase init
# 3. Link to your remote project
supabase link --project-ref <your-project-ref>
# 4. Pull the current remote schema
supabase db pull
# 5. Make changes locally, then push
supabase db push
To remove your stored credentials:
supabase logout