@builder.io/sdk-react-nextjs

中文文档
0.26.2发布于 2026/10/20TypeScriptESM + CJS构建来源已验证近 30 天下载 4570

Builder.io RSC SDK for NextJS App Directory

原始使用文档
文档目录7 节
  1. When should I use this SDK (please read carefully)
  2. Minimum supported version
  3. Usage
  4. Mitosis
  5. Feature Support
  6. Getting Started
  7. Examples

When should I use this SDK (please read carefully)

  • you should ONLY use this SDK if you are trying to register your RSCs (react server components) in Builder. That is its only advantage over our standard React SDKs.
  • our Gen1 and Gen2 React SDKs also integrate with Next.js, but their supported Next.js versions must be checked separately in the framework version matrix. They do not support registration of RSCs.
  • this SDK only works in the NextJS App Directory.

To allow registering RSCs, this SDK must make compromises. Most notably:

  • it does not support interactive Builder features within the rendered content (such as updating dynamic bindings, state, actions etc.). As of today, there are no workarounds around these limitations, due to how RSCs work. See the features grid for more information.
  • the visual editor experience is laggy, as it requires network roundtrips to the customer's servers for each edit. We are working on improving this.

this SDK is marked as "Beta" due to the missing features mentioned above. It is however actively maintained and developed alongside all other SDKs.

Builder.io React NextJS SDK (BETA)

This is the Builder NextJS SDK, @builder.io/sdk-react-nextjs. It is intended to be used only with NextJS's app directory, and has hard dependencies on NextJS-specific functionality that only works in the app directory.

Minimum supported version

The peerDependencies permit Next.js >=13.5.9 and React and React DOM >=18.2.0. These installation ranges apply only to this RSC-registration SDK; its E2E-tested minimum is Next.js 14.2.25 with React and React DOM 18.2.0 (Next.js 14 is no longer supported upstream); see the framework version matrix. Standard Gen1 and Gen2 React SDK integrations have separate Next.js support evidence.

Usage

When registering a custom component, you will need to add the isRSC: true option to the component. For example:

// CatFacts.tsx
async function CatFacts() {
  const catFacts = await fetch('https://cat-fact.herokuapp.com/facts').then(
    (x) => x.json()
  );
  return (
    <div>
      Here are some cat facts from an RSC:
      <ul>
        {catFacts.slice(3).map((fact) => (
          <li key={fact._id}>{fact.text}</li>
        ))}
      </ul>
    </div>
  );
}

export const CatFactsInfo = {
  name: 'CatFacts',
  component: CatFacts,
  // You must add the below option or the SDK will fail to render.
  isRSC: true,
};

And in your page.tsx, you can use the custom component like this:

// page.tsx
import {
  Content,
  fetchOneEntry,
  getBuilderSearchParams,
} from '@builder.io/sdk-react-nextjs';
import { CatFactsInfo } from './CatFacts';

export default async function Page(props) {
  const urlPath = '/' + (props.params?.slug?.join('/') || '');

  const content = await fetchOneEntry({
    model: 'page',
    apiKey,
    options: getBuilderSearchParams(props.searchParams),
    userAttributes: { urlPath },
  });

  return (
    <Content
      content={content}
      model="page"
      apiKey={apiKey}
      customComponents={[CatFactsInfo]}
    />
  );
}

For more usage information, look at the examples.

Mitosis

This SDK is generated by Mitosis. To see the Mitosis source-code, go here.

Feature Support

To check the status of the SDK, look at these tables.

Getting Started

npm install @builder.io/sdk-react-nextjs

Examples

版本与发布记录

@builder.io/sdk-react-nextjs 共发布 159 个版本,首次发布于 2023/07/27;过去 12 个月发布了 25 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.26.2latest2026/10/2019 天前
0.26.12026/10/061 个月前
0.26.02026/10/051 个月前
0.25.192026/10/021 个月前
0.25.182026/09/301 个月前
0.25.172026/09/291 个月前

其他发布通道:dev → 0.14.30-0。

关于 @builder.io/sdk-react-nextjs 的常见问题

@builder.io/sdk-react-nextjs 是什么?

Builder.io RSC SDK for NextJS App Directory

如何安装 @builder.io/sdk-react-nextjs?

在项目目录运行 npm install @builder.io/sdk-react-nextjs,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:next(>=13.5.9)、react(>=18.2.0)、react-dom(>=18.2.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@builder.io/sdk-react-nextjs 支持 TypeScript 吗?

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

@builder.io/sdk-react-nextjs 支持 ESM 还是 CommonJS?

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

@builder.io/sdk-react-nextjs 可以商用吗?

@builder.io/sdk-react-nextjs 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@builder.io/sdk-react-nextjs 的下载量有多少?

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

@builder.io/sdk-react-nextjs 还在维护吗?

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