Supabase CLI
Develop locally and deploy to Supabase
Description
The Supabase CLI enables local development and deployment of Supabase projects. It manages database migrations, generates TypeScript types from your schema, runs a full local Supabase stack (Postgres, Auth, Storage, Edge Functions), and handles deployments to hosted Supabase projects.
Install
brew install supabase/tap/supabasenpm i -g supabaseAI Summary
Develop Supabase projects locally with a full stack (Postgres, Auth, Storage, Edge Functions) and deploy migrations and functions to hosted Supabase. Generate types, manage schemas, and test locally.
Capabilities
- + Run a full local Supabase stack with Docker (Postgres, Auth, Storage, Realtime)
- + Create, apply, and manage database migrations
- + Generate TypeScript types from the database schema
- + Develop and deploy Edge Functions (Deno-based serverless)
- + Seed databases and manage test data
- + Diff remote and local database schemas
- + Link local projects to hosted Supabase projects
Use When
- → Developing Supabase projects with local database and auth
- → Managing database migrations for Supabase-backed applications
- → Generating TypeScript types from Postgres schema
- → Deploying Edge Functions to Supabase
- → Need a local Postgres instance that mirrors production
Avoid When
- x Not using Supabase as a backend (use raw Postgres or other BaaS)
- x Need infrastructure beyond what Supabase provides (use AWS or GCP)
- x Production database administration at scale (use dedicated DBA tools)
Usage Patterns
Start local development
supabase start Starts all local Supabase services and outputs connection URLs and keys
Generate TypeScript types
supabase gen types typescript --local > src/types/supabase.ts Generates type definitions from the local database schema
Create and push a migration
supabase migration new add_profiles && supabase db push Creates a migration file, then pushes all pending migrations to remote
Deploy an Edge Function
supabase functions deploy my-function Deploys a Deno-based Edge Function to the hosted project
Input / Output
0 Success 1 Error Typical Pipelines
supabase start && supabase gen types typescript --local > src/types/supabase.ts supabase db diff --use-migra -f new_changes && supabase db push supabase functions deploy --no-verify-jwt my-function && supabase functions list