@cratis/components.primereact

中文文档
4.40.0发布于 2026/11/04MITTypeScriptES Module零依赖构建来源已验证近 30 天下载 7855

PrimeReact 11 presentation adapter for Cratis Components renderer ABI v1.

原始使用文档
文档目录4 节
  1. Install
  2. Application-owned provider and license
  3. Styling and SSR
  4. Peer policy

@cratis/components.primereact

PrimeReact 11 adapter for the nine stable presentation slots in the Cratis Components renderer ABI v1. The package shares the Components repository release version while the renderer ABI remains versioned separately. It exports one stable CratisPresentationUiLibrary manifest, primeReactUiLibrary. This certifies nine-slot primitive adaptation, never full-catalog replacement. PrimeReact 10 is supported separately by @cratis/components.primereact10.

Versions: each release of @cratis/components.primereact is published at the same version as @cratis/components and declares a peer on exactly that version. Install and upgrade the two packages together at the same version.

Install

npm install @cratis/components.primereact@^4 @cratis/components@^4 \
  @primereact/core@^11 @primereact/ui@^11 primereact@^11 \
  @primeuix/themes@^3 react@^19 react-dom@^19

Node-based build, test, and server-rendering environments require Node.js 22 or newer.

The adapter uses PrimeReact 11 styled components. It covers Button, IconButton, TextInput, TextArea, Checkbox, Radio, Switch, ProgressBar, and Surface. The five atomic interaction slots are not part of this profile.

Application-owned provider and license

PrimeReact 11 requires a license key. The application owns that key and passes it directly to its outer PrimeReactProvider; Components never receives, stores, copies, logs, serializes, or proxies it. PrimeReact's runtime context deliberately omits the key, so the application also passes one non-secret boolean attestation to CratisComponentsProvider.

import { PrimeReactProvider } from '@primereact/core/config';
import Aura from '@primeuix/themes/aura';
import { CratisComponentsProvider } from '@cratis/components';
import { primeReactUiLibrary } from '@cratis/components.primereact';

const primeUiLicenseKey = import.meta.env.VITE_PRIMEUI_LICENSE_KEY;

export const Application = () => (
    <PrimeReactProvider license={primeUiLicenseKey} theme={{ preset: Aura }}>
        <CratisComponentsProvider
            value={{ locale: 'en-US' }}
            library={primeReactUiLibrary}
            rendererSetup={{
                'cratis-primereact.license-configured': Boolean(primeUiLicenseKey),
            }}
        >
            <main>Application content</main>
        </CratisComponentsProvider>
    </PrimeReactProvider>
);

Components that execute commands or run queries also need Arc's <Arc> provider from @cratis/arc.react around this tree; neither the adapter nor CratisComponentsProvider replaces it.

The adapter throws CRATIS-UI-1005 synchronously when either the outer provider or the attestation is absent. Setting the attestation to true is an application assertion that the key was actually supplied; it is not a substitute for doing so. This prevents Components from creating a second provider and fails before adapter content when setup was not attested. The adapter does not validate the key and cannot guarantee that PrimeUI will accept it or omit its own license notice. For development without a key, select the built-in Core renderer explicitly instead of selecting this adapter; a missing attestation never triggers a license fallback.

Obtain a key from PrimeUI. For Vite, expose the application-owned key as VITE_PRIMEUI_LICENSE_KEY only in the client build that mounts PrimeReact. In CI or a publishing pipeline, map a protected PRIMEUI_LICENSE_KEY secret into that build variable without echoing it or writing it to package artifacts. The adapter package itself reads no license environment variable and includes no key.

Styling and SSR

The application chooses the PrimeReact theme on its outer provider. The package's static metadata uses VITE_PRIMEUI_LICENSE_KEY only as documentation/discovery metadata; no runtime lookup occurs. All nine slots produce deterministic SSR output, and the representative Button fixture hydrates without a mismatch. The host remains responsible for PrimeReact's provider, theme, CSP, and style collection/injection requirements.

Peer policy

PrimeReact packages are bounded to >=11 <12, PrimeUX themes to >=3 <4, and React/ReactDOM to React 19. Vendor packages are peers and are never bundled. The packed consumer matrix proves PrimeReact 11.0.0 and 11.2.0 with @primeuix/themes 3.0.0; the adapter's own build and tests use 11.1.0.

The source manifest declares @cratis/components >=4 <5, the Components major whose renderer ABI and stable presentation profile the adapter implements. The release step replaces that range with the exact release version, so a published adapter requires the @cratis/components release it shipped with.

See CONFORMANCE.md for bounded evidence and THIRD_PARTY_NOTICES.md for upstream licensing.

版本与发布记录

@cratis/components.primereact 共发布 83 个版本,首次发布于 2026/08/31;过去 12 个月发布了 83 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
4.40.0latest2026/11/046 天前
4.39.52026/11/046 天前
4.39.42026/11/047 天前
4.39.32026/11/037 天前
4.39.22026/11/037 天前
4.39.12026/11/037 天前

其他发布通道:bootstrap → 0.0.0。

关于 @cratis/components.primereact 的常见问题

@cratis/components.primereact 是什么?

PrimeReact 11 presentation adapter for Cratis Components renderer ABI v1.

如何安装 @cratis/components.primereact?

在项目目录运行 npm install @cratis/components.primereact,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^19.0.0)、react-dom(^19.0.0)、primereact(>=11 <12)、@primereact/ui(>=11 <12)、@primereact/core(>=11 <12)、@primeuix/themes(>=3 <4)、@cratis/components(4.40.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@cratis/components.primereact 支持 TypeScript 吗?

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

@cratis/components.primereact 支持 ESM 还是 CommonJS?

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

@cratis/components.primereact 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@cratis/components.primereact 可以商用吗?

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

@cratis/components.primereact 的下载量有多少?

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

@cratis/components.primereact 还在维护吗?

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