# Supabase CLI
> Develop locally and deploy to Supabase

## 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

## When to Use
- 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

## When NOT to Use
- Not using Supabase as a backend (use raw Postgres or other BaaS)
- Need infrastructure beyond what Supabase provides (use AWS or GCP)
- Production database administration at scale (use dedicated DBA tools)

## Key Flags
- `start`: Start the local Supabase stack (Postgres, Auth, Storage, etc.)
- `stop`: Stop the local Supabase stack
- `db push`: Push local migrations to the remote database
- `gen types typescript`: Generate TypeScript types from the database schema
- `migration new`: Create a new blank migration file
- `functions deploy`: Deploy Edge Functions to the hosted project

## 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
- **stdin**: SQL for some database commands
- **stdout**: Connection strings, migration status, and deployment output

## Installation
- **homebrew**: `brew install supabase/tap/supabase`
- **npm**: `npm i -g supabase`

## Related Tools
- [firebase-cli](/tools/firebase-cli) (alternative): Firebase is a competing BaaS platform; Supabase is the open-source alternative
- [docker](/tools/docker) (complementary): Supabase CLI uses Docker to run the local development stack
- [flyctl](/tools/flyctl) (complementary): Self-host Supabase on Fly.io for custom deployments

---
Source: https://littlescripts.sh/tools/supabase
