# @appduct/react-native 中文文档

规范地址：https://npmcn.com/package/%40appduct/react-native/

版本：0\.16\.0
npm 元数据更新时间：2026-10-21T20:04:38.860Z
中文译文更新时间：2026-11-06T11:25:39.213Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40appduct/react-native
原文对照：https://npmcn.com/package/%40appduct/react-native/?lang=original
项目主页：https://github.com/callstackincubator/appduct/tree/main/packages/react-native#readme
源码仓库：https://github.com/callstackincubator/appduct

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：565 kB，117 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：2 个
- peer 依赖：expo \>=54\.0\.0，react \*，react-native \*
- 首次发布：2026-09-15T14:58:57.507Z
- 最新版本发布：2026-10-21T20:04:38.502Z
- 近 30 天下载量：16866（2026-10-07 至 2026-11-05，npm 官方下载统计）
- 已发布版本数：10（近 12 个月 10 个）

## 中文简介

React Industrial SDK for Appution:注册工具 代理,测试或终端可以在您运行的应用程序中调用.

## 安装

```sh
npm install @appduct/react-native
```

也可以使用：`pnpm add @appduct/react-native`、`yarn add @appduct/react-native`、`bun add @appduct/react-native`

## README

[![Appduct by Callstack. Your app is an MCP server now: your agent calls its functions over MCP, on iOS, Android, React Native, Flutter and web.](https://raw.githubusercontent.com/callstackincubator/appduct/main/.github/assets/readme-banner.png)](https://callstackincubator.github.io/appduct/)

# React 本地应用程序

从终端、测试跑道或AI代理中调用运行中的 React Industrial app 的函数 。 在 JavaScript 中注册工具 `@appduct/react-native`;只有您注册的工具才能到达.

## 所需资源

-   与新建筑反应原生. iOS需要15.1或更新.
-   博览会开发或赤裸的回放原生应用程序 。 去不运行 Apputual 的本地模块.
-   这个 `appduct` 电脑上的CLI: `npm install -g appduct` (节点20或更新.

## 开始

安装 SDK 和 Zod 4 :

```bash
npm install @appduct/react-native zod@^4
```

对于 Expo 应用程序, 设置 URL 方案 `app.json`数字 :

```json
{
  "expo": {
    "scheme": "myapp"
  }
}
```

对于赤裸反射原生,完成 [本地链接设置](https://callstackincubator.github.io/appduct/install/react-native/#set-up-the-app) 连接前.

导入 `/auto` 在您的 JS 条目文件中接收链接并恢复会话 :

```ts
import "@appduct/react-native/auto";
```

在您的应用程序根附近的组件中注册一个工具 :

```tsx
import { useAppductTool } from "@appduct/react-native";
import { z } from "zod";

export function AppductTools() {
  useAppductTool({
    name: "seed_cart",
    description: "Fill the cart with test items.",
    inputSchema: z.object({ items: z.number() }),
    outputSchema: z.object({ added: z.number() }),
    handler: async ({ items }) => ({ added: items }),
  });

  return null;
}
```

挂载 `<AppductTools />` 在您的应用程序中。 重建并运行博览会开发客户端:

```bash
npx expo run:ios
```

对于"赤裸回放原生",在iOS上安装吊舱并照常重建. 在另一个终端, 从您的应用程序的项目根:

```bash
appduct sessions link --scheme myapp --open ios-sim
appduct tools ls
appduct tools call seed_cart --input '{"items":3}'
```

工具返回 `{"added":3}`。用于Android,使用 `npx expo run:android` 并记录您安装的建筑的编号 `appduct init --scheme myapp --android-app-id com.example.shop`,然后使用 `--open android`。 。 。 .

## 事情要知道这一点

-   **挂载该工具的注册组件 .** `useAppductTool` 注册并调用最新的处理器。 使用 `registerTool` 外部反应; 见 [API 参考](https://callstackincubator.github.io/appduct/reference/react-native-api/)。 。 。 .
-   **选择一个方案.** Zod 4直接工作. 其他验证人可能需要 `{ schema, jsonSchema }` 成对; 生 JSON Schema 工作不需要运行时间验证. 输入必须接受对象。 见 [示马斯](https://callstackincubator.github.io/appduct/guides/writing-tools/#choose-a-schema-form)。 。 。 .
-   **给慢工具一个超时 .** 电话有10秒 除非登记 `timeoutMs`。见 [长期工具](https://callstackincubator.github.io/appduct/guides/writing-tools/#long-running-tools)。 。 。 .
-   **过程死亡后重新连接 .** `/auto` 在Metro重新装入后恢复会话,并在短网投放后恢复会话. 杀死应用程序需要一个新的链接. 如果你处理连接自己,打电话 `restoreSession()`; 见 [手动处理链接](https://callstackincubator.github.io/appduct/install/react-native/#handle-links-yourself)。 。 。 .
-   **为 Web 构建配置地铁 .** 将您的地铁配置包入 `withAppduct` 在网络上使用相同的工具;见 [构建变体](https://callstackincubator.github.io/appduct/guides/build-variants/#strip-appducts-javascript-too)。 。 。 .

## 发行构建

Appution的本土模块默认包含在调试构建中. 缺席时,登记无效 `connect()` 拒绝方式 `appduct_disabled`。要将其纳入内部释放构建或剥去其JavaScript,请遵循 [构建变体](https://callstackincubator.github.io/appduct/guides/build-variants/)用钩子 `{ enabled }` 选项以打开单个工具.

在分配前将包含的构件插入到您的密钥中 。 请检查access-date=中的日期值 (帮助)

```bash
appduct doctor build/Shop.ipa --assert-absent
```

## 学多点

-   [反应原生设置](https://callstackincubator.github.io/appduct/install/react-native/): 博览会、赤裸的应用程序和故障排除
-   [API 参考](https://callstackincubator.github.io/appduct/reference/react-native-api/): 出入口、钩子、事件和配置
-   [写入工具](https://callstackincubator.github.io/appduct/guides/writing-tools/):说明、分组和取消
-   [连接代理](https://callstackincubator.github.io/appduct/guides/agents/) 超过 MCP
-   [警卫](https://callstackincubator.github.io/appduct/guides/security/): 信任和密钥指针
-   [反应原生游乐场](https://github.com/callstackincubator/appduct/blob/main/playground/README.md): 可运行的示例

## 由 Calltack 制作

`appduct` 是一个开源项目,将永远自由使用。 如果你觉得这很酷,请 显示它. [调用](https://callstack.com/?utm_source=github.com&utm_medium=referral&utm_campaign=appduct&utm_term=readme-with-love) 一群反动和反动的本地怪人 联系我们 [你好@ callstack.com](mailto:hello@callstack.com) 如果你需要帮忙的话 或者只是想打个招呼!

喜欢这个项目吗 [加入队伍吧](https://callstack.com/careers/?utm_campaign=Senior_RN&utm_source=github&utm_medium=readme) 谁为客户做惊人的事情 驱动 React Independent Open Source

## 常见问题

### @appduct/react-native 是什么？

React Industrial SDK for Appution:注册工具 代理,测试或终端可以在您运行的应用程序中调用\.

### 如何安装 @appduct/react-native？

在项目目录运行 npm install @appduct/react-native，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：react（\*）、react-native（\*）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @appduct/react-native 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @appduct/react-native 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @appduct/react-native 可以商用吗？

@appduct/react-native 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @appduct/react-native 的下载量有多少？

根据 npm 官方下载统计，@appduct/react-native 在 2026/10/07 – 2026/11/05 这 30 天内被下载 16,866 次，日均约 562 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @appduct/react-native 还在维护吗？

最新版本 0\.16\.0 发布于 2026/10/22（16 天前）；至今共发布 10 个版本，其中过去 12 个月发布了 10 个；首次发布于 2026/09/15。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

