@teamkeel/client-react

中文文档
0.501.0发布于 2026/11/02ASL (Apache 2.0)TypeScriptCommonJS零依赖

React helpers for Keel clients

原始使用文档

@teamkeel/client-react

Create a fully typed useKeel() hook from a generated Keel client.

Install

npm i @teamkeel/client-react

Usage

Create the KeelProvider and useKeel components by passing your generated APIClient into the keel function from this package.

N.B. See here for documentation on generating a client

import { APIClient } from "../keelClient";
import { keel } from "@teamkeel/client-react";
export const { KeelProvider, useKeel } = keel(APIClient);

Wrap your app with the exported KeelProvider and set the endpoint for you API.

The endpoint is the base URL + the api name (if you haven't manually set an API name this is api). This url can be found in the Keel web console or in the output of keel run in your terminal.


<KeelProvider endpoint="https://myproject.keelapps.xyz/api/">
    <App />
</KeelProvider>

Now you can use the typed useKeel hook in any component within your app. You can read more here on how to use the client.

function MyComponent() {
    const keel = useKeel();
}

版本与发布记录

@teamkeel/client-react 共发布 453 个版本,首次发布于 2023/07/21;过去 12 个月发布了 101 个版本。

版本发布日期距今
0.501.0latest2026/11/02今天
0.500.02026/10/304 天前
0.499.02026/10/294 天前
0.498.02026/10/286 天前
0.497.02026/10/2112 天前
0.496.02026/10/2013 天前

其他发布通道:rc-next → 0.366.2,dev → 0.366.3-release-updates1,prerelease → 0.380.0-prerelease.2,next → 0.451.1-next.1。

关于 @teamkeel/client-react 的常见问题

@teamkeel/client-react 是什么?

龙骨客户端的React助手

如何安装 @teamkeel/client-react?

在项目目录运行 npm install @teamkeel/client-react,或使用 pnpm add / yarn add / bun add。

@teamkeel/client-react 支持 TypeScript 吗?

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

@teamkeel/client-react 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@teamkeel/client-react 可以商用吗?

@teamkeel/client-react 使用 ASL (Apache 2.0) 许可。声明的许可为 ASL (Apache 2.0),请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@teamkeel/client-react 还在维护吗?

最新版本 0.501.0 发布于 2026/11/02(今天);至今共发布 453 个版本,其中过去 12 个月发布了 101 个;首次发布于 2023/07/21。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。