Supabase CLI | Supabase Docs
Key Points
- 1The Supabase CLI facilitates local Supabase development, allowing users to initialize and launch the entire stack on their machine using `supabase init` and `supabase start`.
- 2Running the local stack requires Docker or compatible container tools, along with Node.js 20+ for CLI installation, and downloads necessary Docker images on the first launch.
- 3Upon starting, the CLI provides local URLs and keys for accessing the Supabase API, database, Studio, Mailpit, and other integrated development tools.
The Supabase CLI is a command-line interface tool engineered to facilitate local development, deployment, and CI/CD workflows for applications integrated with the Supabase platform. Its core methodology centers on orchestrating a comprehensive, containerized development stack locally, replicating the Supabase cloud environment through the judicious use of Docker containers.
Operational Flow and Components: The initial setup involves invoking supabase init within a designated project directory, which scaffolds the necessary configuration files within a new supabase/ folder, amenable to version control. Subsequent execution of supabase start initiates the launch of the entire Supabase service suite via Docker images. This process, particularly on its inaugural run, involves the download and instantiation of multiple container images. The full local stack typically includes:
- A PostgreSQL database instance, accessible via
DB URL: postgresql://postgres:postgres@localhost:54322/postgres. - An API Gateway, powered by PostgREST, exposing the database schema via a RESTful interface at
API URL: http://localhost:54321. - Supabase Studio, a graphical user interface for database management and exploration, available at
Studio URL: http://localhost:54323. - Mailpit, a local SMTP server for capturing and inspecting emails generated by the application, accessible at
Mailpit URL: http://localhost:54324. - An Analytics service.
- An internal database diff tool.
anon and service_role keys (eyJh......).Maintenance and Lifecycle Management: Updating the CLI, when installed via npm, is performed using npm update supabase --save-dev. A critical aspect of managing the local environment is handling database schema changes and data persistence. Before upgrading or for significant state resets, the CLI mandates stopping all running Supabase containers and optionally deleting their associated data volumes to ensure a clean state for applying new migrations. This can involve:
- Generating a schema diff using
supabase db diff -f my_schema. - Dumping local data for backup with .
- Stopping services and discarding local data volumes via
supabase stop --no-backup.
supabase stop command halts the containerized services while preserving the local database state.