Loading...
Loading...
Supabase CLI commands for local development, migrations, project management, and deployment. Use when working with Supabase CLI, starting local dev, managing migrations, or deploying changes.
npx skill4agent add adaptationio/skrillz supabase-cli| Task | Command |
|---|---|
| Install CLI | |
| Login | |
| Init project | |
| Link to remote | |
| Start local stack | |
| Stop local stack | |
| Check status | |
| Create migration | |
| Push to remote | |
| Pull from remote | |
| Reset local DB | |
| Generate types | |
# NPM (recommended for projects)
npm install supabase --save-dev
npx supabase [command]
# Homebrew (macOS/Linux)
brew install supabase/tap/supabase
# Scoop (Windows)
scoop bucket add supabase https://github.com/supabase/scoop-bucket.git
scoop install supabasesupabase initsupabase/config.tomlsupabase/migrations/supabase/seed.sqlsupabase link --project-ref <project-ref>supabase startAPI URL: http://localhost:54321
DB URL: postgresql://postgres:postgres@localhost:54322/postgres
Studio URL: http://localhost:54323
Inbucket URL: http://localhost:54324# Stop and save data
supabase stop
# Stop and delete all data
supabase stop --no-backupsupabase statussupabase migration new create_users_tablesupabase/migrations/<timestamp>_create_users_table.sql# Make changes locally, then generate migration
supabase db diff -f my_schema_changes
# Diff against specific schemas
supabase db diff -f changes --schema public,extensions# Apply pending migrations locally
supabase migration up
# Push to remote
supabase db push
# Preview what would be pushed
supabase db push --dry-runsupabase db pullsupabase db resetsupabase migration list# Rollback last n migrations
supabase migration down --count 1
# Rollback specific number
supabase migration down --count 3# Combine multiple migrations into one
supabase migration squash --version 20240101000000
# Squash all migrations up to version
supabase migration squash --version <target_version># From local database
supabase gen types typescript --local > database.types.ts
# From linked remote
supabase gen types typescript --linked > database.types.ts
# From specific project
supabase gen types typescript --project-id "your-id" > database.types.tssupabase functions new hello-worldsupabase/functions/hello-world/index.ts# Serve all functions
supabase functions serve
# Serve specific function
supabase functions serve hello-world
# With env file and no JWT
supabase functions serve --env-file .env --no-verify-jwt# Deploy all functions
supabase functions deploy
# Deploy specific function
supabase functions deploy hello-world
# Deploy without JWT verification (for webhooks)
supabase functions deploy webhook-handler --no-verify-jwtcurl -i --request POST \
'http://localhost:54321/functions/v1/hello-world' \
--header 'Authorization: Bearer <ANON_KEY>' \
--header 'Content-Type: application/json' \
--data '{"name":"Functions"}'# Set secret
supabase secrets set API_KEY=abc123
# Set multiple secrets
supabase secrets set API_KEY=abc123 DB_PASSWORD=secret
# Set from .env file
supabase secrets set --env-file .env
# List secrets
supabase secrets list
# Remove secret
supabase secrets unset API_KEY# List organizations
supabase orgs list
# List projects
supabase projects list
# Create project
supabase projects create <name> --org-id <id> --region <region>
# Delete project
supabase projects delete --project-ref <ref>
# Update remote config from local
supabase projects update-config# Cache hit ratio
supabase inspect db cache-hit --linked
# Unused indexes
supabase inspect db unused-indexes --local
# Table bloat
supabase inspect db bloat --linked
# Long running queries
supabase inspect db long-running-queries --linked
# Active connections
supabase inspect db role-connections --linked# Dump roles
supabase db dump --linked -f roles.sql --role-only
# Dump schema
supabase db dump --linked -f schema.sql
# Dump data
supabase db dump --linked -f data.sql --use-copy --data-onlypsql --single-transaction \
--file roles.sql \
--file schema.sql \
--command 'SET session_replication_role = replica' \
--file data.sql \
--dbname [CONNECTION_STRING]| Flag | Description |
|---|---|
| Verbose output |
| Use local database |
| Use linked remote |
| Specific project |
| Connection string |
| Preview without executing |
| Output to file |