@frontera-sdk/core

中文文档
1.53.53发布于 2026/11/15Apache-2.0TypeScriptES Module近 30 天下载 2.2万

The Frontera SDK: the app runtime and typed clients for Blueprint, Agents, Chat, Knowledge, Workflows, Functions and Channels, one subpath per area.

原始使用文档
文档目录5 节
  1. Every area, one subpath each
  2. Entry points
  3. Embedded application lifecycle
  4. Modules
  5. License

@frontera-sdk/core

The Frontera SDK, in one package: the runtime a Frontera app mounts on (the postMessage bridge to the platform host, the app bootstrap and a typed platform client), and a typed client for each area of the platform.

bun add @frontera-sdk/core react react-dom @tanstack/react-query

React and TanStack Query are needed only by the React subpaths (/react, …/hooks, …/provider); a script or a server imports the clients without them. The package is compiled ESM with type declarations: bundlers, Node.js, Bun and edge runtimes use it as it is. Its TypeScript ships beside the build, under src/, and the declaration and source maps lead there: Go to Definition opens the implementation, a stack trace (node --enable-source-maps, bundlers, browsers) names the source line, and a coding agent reading node_modules finds the code and its comments, not only signatures.

Every area, one subpath each

AreaImport fromGuide
App runtime and client@frontera-sdk/core/react, /client, /config, /errors, …this README
Blueprint: queries and governed Actions@frontera-sdk/core/blueprint/<subpath>docs/blueprint.md
Agents: metrics and conversations@frontera-sdk/core/agents/<subpath>docs/agents.md
Chat with an Agent@frontera-sdk/core/chat/<subpath>docs/chat.md
Knowledge@frontera-sdk/core/knowledge/<subpath>docs/knowledge.md
Workflow runs@frontera-sdk/core/workflow/<subpath>docs/workflow.md
Functions (Node.js and Bun)@frontera-sdk/core/functions, /functions/<subpath>docs/functions.md
Custom channels@frontera-sdk/core/channels/<subpath>docs/channels.md

The packages @frontera-sdk/blueprint, @frontera-sdk/agents, @frontera-sdk/chat, @frontera-sdk/knowledge, @frontera-sdk/workflow and @frontera-sdk/functions keep releasing at the same version as re-exports of these subpaths: @frontera-sdk/blueprint/hooks and @frontera-sdk/core/blueprint/hooks are one module, so code on either name works, and both can be used in one App.

The rest of this README covers the app runtime.

import { FronteraAppProvider } from '@frontera-sdk/core/react'

export function Providers({ children }: { children: React.ReactNode }) {
  return <FronteraAppProvider>{children}</FronteraAppProvider>
}

FronteraAppProvider selects one configured transport before connecting: embedded postMessage bridge, same-origin standalone session, or loopback local session broker. All three synthesize the same BridgeInit, so Blueprint and other domain providers do not need transport-specific branches. A missing transport renders a configuration diagnostic immediately.

With renderWhileConnecting, the provider renders the App while the session connects instead of a loading screen, so a static export carries the App itself and paints before the session is ready. Requests wait for the session and go out with its token. Read what the handshake says with useFronteraConnection(), which is { status: 'connecting', client } until the session is ready; before then useFronteraApp() gives only its client.

The App then renders inside a Suspense boundary whose fallback is loading, for as long as it runs: anything that suspends with no boundary of its own (a suspense read, a lazy component, an update outside a transition) shows loading in place of the App. During a static export, a suspense read is left to the browser. That is quiet in Next.js, which recognises the error the read fails with as its own bailout to client rendering; other frameworks still render the boundary in the browser, but report the error.

createFronteraApp() remains the Vite compatibility wrapper. Embedded navigate() synchronizes the platform-owned URL; standalone and local Apps own routing themselves.

Entry points

Embedded application lifecycle

useFronteraApp() exposes active and setUnsavedChanges(dirty). Use active to pause optional visible-only work; an inactive app may remain mounted, with its credentials refreshed. Inactivity does not cancel server-side operations.

Report local draft changes explicitly, and report false only after the draft is saved or deliberately discarded. An app that never reports its state is treated as unknown when the platform is asked to release its session. This API does not implement saving for the app or provide recovery after a browser reload.

The injected app-host bridge reports native push, replacement, traversal and fragment changes. A frontera:host-navigate request carries a requestId and relative app path; the bridge replaces the child location and responds with frontera:navigation-ack using the same ID. It does not add a second child history step for a navigation the host already owns. Both directions validate the expected origin and sender window. Older hosts may ignore the new lifecycle messages; older app-host scripts do not support acknowledged navigation.

Modules

ImportWhat it is
@frontera-sdk/core/reactFronteraAppProvider, useFronteraApp, useFronteraConnection, and mode types
@frontera-sdk/core/create-frontera-appapp bootstrap and useFronteraApp
@frontera-sdk/core/clientthe typed platform client
@frontera-sdk/core/configcredential and origin resolution
@frontera-sdk/core/bridge-clientthe host handshake, if you need it directly
@frontera-sdk/core/bridge-protocolthe message types both sides speak
@frontera-sdk/core/app-stateshared, validated app state
@frontera-sdk/core/themeapplying the host's design tokens
@frontera-sdk/core/errorsthe error taxonomy, code mirroring the service

Standalone and local sessions refresh their short-lived App token at 80% of its lifetime. The browser never receives a long-lived workspace key.

Published as TypeScript source. Every consumer is a bundler or tsc, so a build step would emit output the consumer immediately re-transpiles.

License

Apache-2.0. See LICENSE.

版本与发布记录

@frontera-sdk/core 共发布 236 个版本,首次发布于 2026/07/30;过去 12 个月发布了 236 个版本。

版本发布日期距今
1.53.53latest2026/11/151 天前
1.53.522026/11/141 天前
1.53.512026/11/141 天前
1.53.502026/11/141 天前
1.53.492026/11/141 天前
1.53.482026/11/132 天前

关于 @frontera-sdk/core 的常见问题

@frontera-sdk/core 是什么?

The Frontera SDK: the app runtime and typed clients for Blueprint, Agents, Chat, Knowledge, Workflows, Functions and Channels, one subpath per area.

如何安装 @frontera-sdk/core?

在项目目录运行 npm install @frontera-sdk/core,或使用 pnpm add / yarn add / bun add。

@frontera-sdk/core 支持 TypeScript 吗?

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

@frontera-sdk/core 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@frontera-sdk/core 可以商用吗?

@frontera-sdk/core 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@frontera-sdk/core 的下载量有多少?

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

@frontera-sdk/core 还在维护吗?

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