Skip to main content
RapidDev - Software Development Agency
supabase-tutorial

How to Configure the Supabase CLI

Install the Supabase CLI with brew install supabase/tap/supabase (macOS) or npm install supabase --save-dev (any OS). Run supabase init to create the project structure, supabase start to launch local Postgres, Auth, Storage, and Studio, and supabase link to connect to your remote project. The CLI is essential for migrations, Edge Functions, type generation, and local development — it gives you a full Supabase stack on your machine.

What you'll learn

  • How to install the Supabase CLI on macOS, Linux, and Windows
  • How to initialize a project and start the local development stack
  • How to link the CLI to your remote Supabase project
  • How to use the CLI for migrations, Edge Functions, and type generation
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Beginner8 min read15-20 minSupabase CLI v1.100+, macOS, Linux, Windows (via WSL or npm)March 2026RapidDev Engineering Team
TL;DR

Install the Supabase CLI with brew install supabase/tap/supabase (macOS) or npm install supabase --save-dev (any OS). Run supabase init to create the project structure, supabase start to launch local Postgres, Auth, Storage, and Studio, and supabase link to connect to your remote project. The CLI is essential for migrations, Edge Functions, type generation, and local development — it gives you a full Supabase stack on your machine.

Installing and Configuring the Supabase CLI

The Supabase CLI is the command-line tool for local development, database migrations, Edge Functions, and type generation. It runs a complete Supabase stack locally using Docker — including PostgreSQL, Auth (GoTrue), Storage, Realtime, and Studio. This tutorial walks you through installation, project initialization, linking to a remote project, and the essential commands you will use daily.

Prerequisites

  • Docker Desktop installed and running (required for supabase start)
  • A Supabase account at app.supabase.com
  • A terminal (macOS Terminal, Linux shell, or WSL on Windows)
  • Node.js 18+ (if installing via npm)

Step-by-step guide

1

Install the Supabase CLI

The CLI can be installed via Homebrew on macOS, npm for any platform, or as a standalone binary. The Homebrew method is recommended for macOS because it auto-updates and handles PATH configuration. The npm method works everywhere and is ideal for projects where you want the CLI version locked in package.json. After installation, verify it works by running supabase --version.

typescript
1# macOS (recommended)
2brew install supabase/tap/supabase
3
4# Any OS via npm (add to your project)
5npm install supabase --save-dev
6
7# Run via npx if installed via npm
8npx supabase --version
9
10# Linux (direct download)
11brew install supabase/tap/supabase
12# or use npm method above
13
14# Verify installation
15supabase --version

Expected result: The CLI prints its version number, confirming successful installation.

2

Initialize a Supabase project

Navigate to your project directory and run supabase init. This creates a supabase/ folder containing config.toml (project configuration), a migrations/ directory for SQL migration files, a functions/ directory for Edge Functions, and a seed.sql file for seeding your local database. The config.toml file controls local settings like the Studio port, auth configuration, and database extensions. You only need to run init once per project.

typescript
1# Navigate to your project root
2cd your-project
3
4# Initialize Supabase
5supabase init
6
7# This creates:
8# supabase/
9# config.toml (local configuration)
10# migrations/ (SQL migration files)
11# functions/ (Edge Functions)
12# seed.sql (seed data for local dev)

Expected result: A supabase/ directory is created in your project with config.toml and empty migrations/ and functions/ directories.

3

Start the local Supabase stack

Run supabase start to launch a complete Supabase environment on your machine using Docker containers. This includes PostgreSQL, GoTrue (Auth), Storage, Realtime, PostgREST (API), Kong (gateway), and Supabase Studio. The first run downloads Docker images, which may take a few minutes. After startup, the CLI prints all local URLs and keys you need for development. Use these values in your .env.local file.

typescript
1# Start all local services
2supabase start
3
4# Output includes:
5# API URL: http://localhost:54321
6# Studio URL: http://localhost:54323
7# DB URL: postgresql://postgres:postgres@localhost:54322/postgres
8# anon key: eyJhbGciOiJIUzI1NiIs...
9# service_role key: eyJhbGciOiJIUzI1NiIs...
10
11# Copy these to your .env.local:
12# NEXT_PUBLIC_SUPABASE_URL=http://localhost:54321
13# NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIs...
14
15# Check status anytime
16supabase status
17
18# Stop the stack (data is preserved)
19supabase stop

Expected result: Docker containers start and the CLI prints local API URL, Studio URL, database connection string, anon key, and service role key.

4

Log in and link to your remote Supabase project

To push migrations and deploy Edge Functions to your hosted Supabase project, you need to authenticate the CLI and link it to a specific project. Run supabase login to open a browser authentication flow. Then run supabase link with your project reference ID (found in the Dashboard URL or Project Settings). Linking stores the project reference locally so subsequent commands know which remote project to target.

typescript
1# Authenticate with your Supabase account
2supabase login
3
4# Find your project reference ID:
5# Dashboard URL: https://supabase.com/dashboard/project/abcdefghijklmnop
6# The ref is: abcdefghijklmnop
7
8# Link to your remote project
9supabase link --project-ref abcdefghijklmnop
10
11# You may be prompted for your database password
12# (the one you set when creating the project)

Expected result: The CLI is linked to your remote project. You can now run db push, functions deploy, and other remote commands.

5

Run essential CLI commands for daily development

With the CLI configured, here are the commands you will use most often. Create new migrations with supabase migration new, apply them locally with supabase migration up, and deploy to production with supabase db push. Generate TypeScript types from your schema to get full type safety in your application code. Serve Edge Functions locally with hot reload for development, and deploy them when ready.

typescript
1# Create a new migration
2supabase migration new add_projects_table
3# Edit the file in supabase/migrations/
4
5# Apply migration locally
6supabase migration up
7
8# Reset local DB (reapply all migrations + seed)
9supabase db reset
10
11# Push migrations to production
12supabase db push
13
14# Pull remote schema as a local migration
15supabase db pull
16
17# Generate schema diff after Dashboard changes
18supabase db diff -f my_change
19
20# Generate TypeScript types
21supabase gen types typescript --local > src/types/supabase.ts
22
23# Serve Edge Functions locally
24supabase functions serve
25
26# Deploy an Edge Function
27supabase functions deploy my-function
28
29# Set remote secrets
30supabase secrets set STRIPE_KEY=sk_live_...

Expected result: You can create migrations, generate types, serve functions, and deploy to production all from the command line.

Complete working example

supabase-cli-setup.sh
1#!/bin/bash
2# Complete Supabase CLI setup script
3# Run this in your project root directory
4
5# ============================================
6# Step 1: Install the CLI
7# ============================================
8
9# macOS
10brew install supabase/tap/supabase
11
12# Or via npm (recommended for team projects)
13# npm install supabase --save-dev
14
15# Verify
16supabase --version
17
18# ============================================
19# Step 2: Initialize and start local stack
20# ============================================
21
22supabase init
23supabase start
24
25# Save the output you need the API URL and anon key
26# Create .env.local with:
27# NEXT_PUBLIC_SUPABASE_URL=http://localhost:54321
28# NEXT_PUBLIC_SUPABASE_ANON_KEY=<from supabase status>
29
30# ============================================
31# Step 3: Link to remote project
32# ============================================
33
34supabase login
35supabase link --project-ref YOUR_PROJECT_REF
36
37# ============================================
38# Step 4: Create your first migration
39# ============================================
40
41supabase migration new create_initial_schema
42
43# Edit the migration file, then apply:
44supabase migration up
45
46# ============================================
47# Step 5: Generate TypeScript types
48# ============================================
49
50mkdir -p src/types
51supabase gen types typescript --local > src/types/supabase.ts
52
53# ============================================
54# Step 6: Deploy to production
55# ============================================
56
57supabase db push # Push migrations
58supabase functions deploy # Deploy all Edge Functions

Common mistakes when configuring the Supabase CLI

Why it's a problem: Running supabase start without Docker Desktop running, which causes a connection error

How to avoid: Make sure Docker Desktop is installed, running, and has enough allocated memory (at least 4 GB). The CLI uses Docker to run all local services.

Why it's a problem: Forgetting to run supabase link before trying to deploy to production

How to avoid: Run supabase login followed by supabase link --project-ref your-ref to connect the CLI to your remote project. The project ref is in your Dashboard URL.

Why it's a problem: Editing the remote database directly in the Dashboard without pulling changes, causing migration drift

How to avoid: After making changes in the Dashboard, run supabase db diff -f describe_change to capture those changes as a local migration file. Then commit the migration to git.

Why it's a problem: Using the local anon key or URL in production environment variables

How to avoid: Local keys (from supabase status) only work with the local stack. Use the keys from Dashboard > Settings > API for your hosted project.

Best practices

  • Install the CLI as a dev dependency via npm for team projects so everyone uses the same version
  • Commit the entire supabase/ directory to git including config.toml, migrations, and Edge Functions
  • Always create changes as migration files rather than editing the remote database directly
  • Run supabase db reset regularly during development to verify your migrations apply cleanly from scratch
  • Use supabase gen types typescript to generate type-safe client code after every schema change
  • Add CLI commands as npm scripts in package.json for consistency across the team

Still stuck?

Copy one of these prompts to get a personalized, step-by-step explanation.

ChatGPT Prompt

I just started a new project and need to set up the Supabase CLI for local development. Walk me through the complete setup: installing the CLI, initializing the project, starting local services, linking to my remote project, and creating my first migration.

Supabase Prompt

Set up the Supabase CLI for a Next.js project. Initialize the supabase directory, start local services, create a migration for a users profile table, generate TypeScript types, and show me how to deploy everything to my hosted Supabase project.

Frequently asked questions

Do I need Docker to use the Supabase CLI?

Yes, Docker is required for supabase start which runs the local development stack. You do not need Docker for remote-only commands like supabase db push, supabase login, or supabase functions deploy.

How do I update the Supabase CLI?

With Homebrew: brew upgrade supabase. With npm: npm update supabase. Check the current version with supabase --version and compare with the latest release on GitHub.

Can I use the CLI on Windows?

Yes. Install via npm (npm install supabase --save-dev) or use Windows Subsystem for Linux (WSL) with the Homebrew method. Docker Desktop for Windows is required for the local stack.

What is the difference between supabase db push and supabase migration up?

supabase migration up applies migrations to your local database. supabase db push applies migrations to your remote (hosted) Supabase project. Always test locally first, then push to production.

How do I reset my local database to a clean state?

Run supabase db reset. This drops the local database, reapplies all migrations in order, and runs seed.sql. This is useful for testing that your migrations work correctly from scratch.

Can I use the Supabase CLI in CI/CD pipelines?

Yes. Use the npm installation method, set SUPABASE_ACCESS_TOKEN as an environment variable for authentication, and run supabase db push and supabase functions deploy in your pipeline.

Can RapidDev help me set up the Supabase CLI and local development workflow?

Yes. RapidDev can configure your local development environment, set up CI/CD pipelines with the Supabase CLI, and establish migration workflows for your team.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.