Skip to content
Local Development

本地开发与命令行工具

Learn how to develop locally and use the Supabase CLI

要使用本地运行的 Supabase 堆栈来开发你的应用,你需要安装 Supabase CLI 和一个容器运行环境。

🌐 To develop your applications using the locally running Supabase stack, you'll need to install the Supabase CLI and a container runtime.

快速入门 #

🌐 Quickstart

  1. 安装 Supabase CLI:

    1
    npm install supabase --save-dev
  2. 在你的仓库里,初始化本地 Supabase 项目:

    1
    npx supabase init
  3. 启动本地 Supabase 堆栈:

    1
    npx supabase start
  4. 在本地通过 http://localhost:54323 查看你的 Supabase 实例。

本地开发 #

🌐 Local development

使用 Supabase 进行本地开发可以让你在本地计算机的独立环境中进行项目开发。在本地工作有几个好处:

🌐 Local development with Supabase allows you to work on your projects in a self-contained environment on your local machine. Working locally has several advantages:

  1. 更快的开发:你可以马上做出更改并看到结果,无需等待远程部署。
  2. 离线工作:即使没有网络连接,你也可以继续开发。
  3. 性价比高:本地开发是免费的,而且不会消耗你项目的配额。
  4. 增强隐私:开发过程中敏感数据会保留在你的本地机器上。
  5. 安全测试:你可以尝试不同的配置和功能,而不会影响你的生产环境。

一旦设置好,你就可以初始化一个新的 Supabase 项目,启动本地环境,并开始使用本地 Supabase 服务开发你的应用。这包括访问本地 Postgres 数据库、认证、存储以及其他 Supabase 功能。

🌐 Once set up, you can initialize a new Supabase project, start the local stack, and begin developing your application using local Supabase services. This includes access to a local Postgres database, Auth, Storage, and other Supabase features.

命令行接口 #

🌐 CLI

Supabase CLI 是一个工具,允许开发者在本地运行 Supabase 服务,并直接从终端管理托管的项目。它提供了一套用于各种任务的命令,包括:

🌐 The Supabase CLI is a tool that enables developers to run Supabase services locally and manage hosted projects directly from the terminal. It provides a suite of commands for various tasks, including:

  • 搭建和管理本地开发环境
  • 为你的数据库模式生成 TypeScript 类型
  • 处理数据库迁移
  • 管理环境变量和密钥
  • 将你的项目部署到 Supabase 平台

使用命令行工具,你可以简化开发工作流程、自动化重复任务,并在不同环境中保持一致性。这是本地开发和 CI/CD 流水线中都必不可少的工具。

🌐 With the CLI, you can streamline your development workflow, automate repetitive tasks, and maintain consistency across different environments. It's an essential tool for both local development and CI/CD pipelines.

请查看CLI入门指南了解更多信息。

🌐 See the CLI Getting Started guide for more information.