---
title: "使用 Tiptap CLI"
description: "这是一个命令行接口，用于快速安装和配置 Tiptap UI 组件。了解如何在文档中入门！"
canonical_url: "https://tiptap.zhcndoc.com/ui-components/getting-started/cli"
---

# 使用 Tiptap CLI

这是一个命令行接口，用于快速安装和配置 Tiptap UI 组件。了解如何在文档中入门！

Tiptap CLI 帮助您快速搭建编辑器，安装 UI 组件或原件，并更快地配置 Tiptap。它消除了大量的手动工作，让您能够更快地开始构建编辑器功能。

它是为 Vite 或 Next.js 项目设计的。如果您使用其他框架，您需要从 [开源代码库](https://github.com/ueberdosis/tiptap-ui-components) 手动集成 Tiptap。

## 使用方法

```bash
npx @tiptap/cli@latest [command] [options]
```

## 命令

### `init`

初始化您的项目并安装依赖项。此命令会设置您的项目配置，并将任何指定组件作为可编辑的源文件添加进去。

在空目录中运行时，它会搭建一个新的 Vite 或 Next.js 项目；在现有项目中运行时，它会对其进行配置。无论哪种方式，组件都会被复制到您的 `components/` 文件夹中——然后您可以在自己的页面中导入并渲染它们。它们不会自动接入页面，因此新搭建的应用仍会显示框架默认的起始页面，直到您渲染一个组件为止。有关完整流程，请参阅 [Next.js](https://tiptap.zhcndoc.com/ui-components/install/next.md) 或 [Vite](https://tiptap.zhcndoc.com/ui-components/install/vite.md) 指南。

```bash
npx @tiptap/cli@latest init
```

#### 参数

- components: 要添加的组件

#### 选项

```bash
Usage: @tiptap/cli@latest init [options] [components...]

Options:
-f, --framework <framework>   要使用的框架（例如：next, vite）
-c, --cwd <cwd>               工作目录（默认为当前目录）
-s, --silent                  静默输出
--src-dir                     创建新项目时使用 src 目录
```

### `add`

向您的项目添加一个或多个 Tiptap UI 组件或模板。

```bash
npx @tiptap/cli@latest add [components...]
```

#### 示例

```bash
npx @tiptap/cli@latest add button
```

#### 选项

```bash
Usage: @tiptap/cli@latest add [options] [components...]

Arguments:
  components                    要添加的组件

Options:
  -o, --overwrite              覆盖已存在的文件
  -c, --cwd <cwd>              工作目录（默认为当前目录）
  -p, --path <path>            添加组件的路径
  -s, --silent                 静默输出
```

### `info`

获取有关您的项目配置和设置的信息。

```bash
npx @tiptap/cli@latest info
```

#### 选项

```bash
Usage: @tiptap/cli@latest info [options]

Options:
  -c, --cwd <cwd>              工作目录（默认为当前目录）
```

### `login`

登录到您的 Tiptap Cloud 账户，以访问付费组件和模板。

```bash
npx @tiptap/cli@latest login
```

#### 选项

```bash
Usage: @tiptap/cli@latest login [options]

Options:
  -e, --email <email>          您的账户邮箱
  -p, --password <password>    您的账户密码
  --write-config               将认证令牌写入包管理器配置
  -c, --cwd <cwd>              工作目录（默认为当前目录）
```

### `logout`

登出您的 Tiptap Cloud 账户。

```bash
npx @tiptap/cli@latest logout
```

### `status`

查看您的 Tiptap Cloud 身份验证状态和激活的计划。

```bash
npx @tiptap/cli@latest status
```

#### 选项

```bash
Usage: @tiptap/cli@latest status [options]

Options:
  -c, --cwd <cwd>              工作目录（默认为当前目录）
```
