@appduct/react-native

中文文档
0.16.0发布于 2026/10/22MITTypeScriptESM + CJS构建来源已验证近 30 天下载 1.7万

React Native SDK for Appduct: register tools an agent, test or terminal can call in your running app.

原始使用文档
文档目录6 节
  1. Requirements
  2. Getting started
  3. Things to know
  4. Release builds
  5. Learn more
  6. Made with ❤️ at Callstack

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.

Appduct for React Native

Call functions inside your running React Native app from a terminal, a test runner or an AI agent. Register tools in JavaScript with @appduct/react-native; only the tools you register are reachable.

Requirements

  • React Native with the New Architecture. iOS requires 15.1 or newer.
  • An Expo development build or a bare React Native app. Expo Go doesn't run Appduct's native module.
  • The appduct CLI on your computer: npm install -g appduct (Node 20 or newer).

Getting started

Install the SDK and Zod 4:

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

For an Expo app, set a URL scheme in app.json:

{
  "expo": {
    "scheme": "myapp"
  }
}

For bare React Native, complete the native link setup before connecting.

Import /auto once in your JS entry file to receive links and restore sessions:

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

Register a tool in a component mounted near your app's root:

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;
}

Mount <AppductTools /> in your existing app. Rebuild and run the Expo development client:

npx expo run:ios

For bare React Native, install pods on iOS and rebuild as usual. In another terminal, from your app's project root:

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

The tool returns {"added":3}. For Android, use npx expo run:android and record your installed build's id with appduct init --scheme myapp --android-app-id com.example.shop, then use --open android.

Things to know

  • Mount the component that registers the tool. useAppductTool registers while mounted and calls the latest handler. Use registerTool outside React; see the API reference.
  • Choose a schema form. Zod 4 works directly. Other validators may need a { schema, jsonSchema } pair; raw JSON Schema works without runtime validation. Inputs must accept an object. See Schemas.
  • Give slow tools a timeout. Calls get 10 seconds unless registration declares timeoutMs. See Long-running tools.
  • Reconnect after process death. /auto resumes sessions after Metro reloads and short network drops. Killing the app requires a new link. If you handle links yourself, call restoreSession(); see Manual link handling.
  • Configure Metro for Web builds. Wrap your Metro config in withAppduct to use the same tools on Web; see Build variants.

Release builds

Appduct's native module is included in debug builds by default. When it is absent, registration is inert and connect() rejects with appduct_disabled. To include it in an internal release build or strip its JavaScript too, follow Build variants. Use the hook's { enabled } option to gate individual tools.

Pin an included build to your key before distributing it. Check a built app that should exclude Appduct:

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

Learn more

Made with ❤️ at Callstack

appduct is an open source project and will always remain free to use. If you think it's cool, please star it 🌟. Callstack is a group of React and React Native geeks, contact us at [email protected] if you need any help with these or just want to say hi!

Like the project? ⚛️ Join the team who does amazing stuff for clients and drives React Native Open Source! 🔥

版本与发布记录

@appduct/react-native 共发布 10 个版本,首次发布于 2026/09/15;过去 12 个月发布了 10 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.16.0latest2026/10/2216 天前
0.15.12026/10/1622 天前
0.15.02026/10/1226 天前
0.14.02026/10/021 个月前
0.13.02026/09/281 个月前
0.12.02026/09/241 个月前

关于 @appduct/react-native 的常见问题

@appduct/react-native 是什么?

React Native SDK for Appduct: register tools an agent, test or terminal can call in your running app.

如何安装 @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 和提交记录判断。