@dani-builder/strapi-plugin-builder

中文文档
2.5.0发布于 2026/11/10MITTypeScriptESM + CJS近 30 天下载 4167

Daniworks Builder — reusable CMS components, content types, and smart API for Strapi v5

原始使用文档
文档目录7 节
  1. Install
  2. Plugin-owned content types
  3. Extending from your project
  4. Smart API
  5. License
  6. Builder Forms admin
  7. Form submission access

@dani-builder/strapi-plugin-builder

Reusable CMS building blocks for Strapi v5 — 12 content types, 42 block/element/shared components, and a "smart API" that returns fully deep-populated pages and globals in a single request. Powers the Daniworks Builder block-based site builder.

Install

pnpm add @dani-builder/strapi-plugin-builder @strapi/plugin-color-picker @d3levvv/strapi-react-icons-plugin @strapi/provider-upload-aws-s3

The two custom-field peer plugins are required: builder components use their fields (plugin::color-picker.color, plugin::icon-picker.icon), and Strapi only loads plugins listed in your own package.json. Without them the app fails to boot with Could not find Custom Field: plugin::color-picker.color.

Builder also requires the react-intl peer to share the host admin translation context. Install the same version used by your installed @strapi/admin; for Strapi 5.60.0, run pnpm add [email protected] in the CMS. Keep this dependency aligned when upgrading Strapi. A separate copy can make Forms fail with Could not find required intl object even though Strapi provides IntlProvider.

The S3 upload provider is an optional peer for local-only projects, but it must be a direct dependency of the CMS when AWS_BUCKET enables S3, R2, or MinIO. Use @strapi/provider-upload-aws-s3 version 5.36.0 or later within Strapi v5. Strapi resolves upload providers from the consuming application.

Use the package-owned config factories so package upgrades carry storage and media CSP fixes into the application. Compose the package-owned entries with the rest of your application config. In config/plugins.ts:

import {
  builderPlugins,
  builderUpload,
} from "@dani-builder/strapi-plugin-builder/config";

export default ({ env }) => ({
  builder: builderPlugins({ env }),
  upload: {
    config: {
      // Keep application-owned security settings such as deniedTypes here.
      ...builderUpload({ env }),
    },
  },
});

In config/middlewares.ts:

import { builderMiddlewares } from "@dani-builder/strapi-plugin-builder/config";

export default ({ env }) => [
  "strapi::logger",
  "strapi::errors",
  builderMiddlewares({ env }),
  // The remaining Strapi and application middleware entries stay here.
];

With no AWS_BUCKET, uploads use Strapi's local provider. Set AWS_BUCKET for S3; S3-compatible R2 and MinIO deployments can additionally set AWS_ENDPOINT. Endpoint-based configurations enable path-style requests by default and can override that behavior with AWS_FORCE_PATH_STYLE.

Set AWS_ACL=none for buckets with ACLs disabled (such as S3 Bucket owner enforced). This omits the ACL from upload requests and requires provider 5.36.0 or later; older versions replace the omitted ACL with public-read.

builderUpload({ env }) only owns provider settings. Spread it inside the application's upload.config block so Strapi's generated media security settings remain in place. SVG and executable upload denial belongs to the application's upload.config.security.deniedTypes; the factory does not inject or replace it.

Plugin-owned content types

The plugin directly registers all 12 content types as plugin::builder.*. Do not copy schemas into a consumer's src/api directory: that would create conflicting collectionName registrations. Core REST endpoints are available under /api/builder/*.

Legal Document (plugin::builder.legal-document) stores standalone localized content with required title, slug, and Blocks-editor body, plus optional summary and effectiveDate. Use GET /api/builder/legal-documents?filters[slug][$eq]=privacy-policy&locale=en to find a published document; an unknown slug returns an empty data array. Configure Content API token or role permissions explicitly; the plugin does not automatically grant public access. Setup samples are in the CMS content guide.

Inquiry remains a storage target. Submit through the rate-limited POST /api/builder/forms/:slug/submissions; legacy Inquiry routes are removed.

Extending from your project

Add your own blocks to Page.blocks and extra fields to plugin components from src/extensions/builder/strapi-server.ts in your Strapi project — no plugin fork needed. Register populate for custom blocks with strapi.plugin('builder').service('populate').registerBlock(uid, populate). Step-by-step guide with the failure cases to avoid: docs/guides/extending-builder.md. Claude Code users get the same procedure as the builder-extender skill.

Smart API

Deep-populated reads default to published content; authenticated Page requests may explicitly request drafts with status=draft:

MethodEndpointPurpose
GET/api/builder/pagesList pages (minimal populate)
GET/api/builder/pages/:documentIdSingle page, deep block populate
GET/api/builder/globalGlobal settings, deep populate

Consume it with @dani-builder/strapi-client.

License

MIT © HJ-company

Builder Forms admin

Open Builder Forms in the Strapi admin menu to list, inspect and export saved form definitions. Administrators with Builder → Forms → Update permission can also create forms, edit target field selection and order, labels, placeholders, help text, required/hidden settings, enumeration labels and consent text/version. Schema constraints are retained; schema-required fields cannot be removed or made optional. The target selector supports eligible consumer api::* types. Slugs are immutable after creation. Forms with submissions cannot be deleted; the server's error is shown and the row is retained.

Export downloads the saved portable JSON definition. Import accepts a JSON file or pasted JSON; use the list to create a new form, or the detail screen to replace the saved definition with a matching slug. New imports start at form version 1; replacement imports and ordinary saves increment the server-owned form version. The separate consent version is preserved. Ordinary saves preserve existing notification configuration; exported credentials are masked, so imports do not transfer notification secrets to another CMS. Notification configuration and submission management screens are deferred to a later release.

Optional shared.tracking metadata is available on every block, shared.link, and shared.action. Existing content may omit it; Smart Page/Global and client REST populates include it at nested link/action depths. Renderer DOM propagation is handled separately.

Form submission access

Forms default to public submission. In the form editor, administrators with the plugin::builder.forms.manage-submission-access permission can select server-only access and link content API tokens. Grant this new permission to non-Super Admin roles that manage submission access; forms.update alone does not allow a policy-bearing export to be imported again. Create, update, and import requests containing either access field return 403 without the new permission. Only token ID, name and expiry metadata are shown. A protected form with no linked tokens blocks all submissions. Deleted or reissued tokens need to be linked again; renaming a token preserves its ID and access.

Public form definitions never include access policy or token IDs. Portable exports include the policy but omit environment-specific token IDs. Any import containing a policy clears existing token links, even if the policy is unchanged. A protected form then blocks submissions until tokens are relinked. An overwrite without a policy preserves the existing policy and bindings. At startup, legacy forms with both access database fields null are migrated to public access with an empty token list. Repeated startup preserves explicit policies and form versions. Changes to access increment the form version without changing the consent version.

The existing content API authorization must allow plugin::builder.submission.create. A protected form additionally requires a valid API token whose internal ID is in its allowlist, including full-access tokens. User JWTs cannot submit protected forms. Strapi rejects invalid, revoked, or expired credentials with 401 and denies unauthorized actions with 403. With no credentials, Strapi may return 403 before form lookup if Public lacks the action; otherwise protected forms return 401. HOME_PROXY_TOKEN controls trusted proxy IP handling only and grants no submission access. Token authentication may update Strapi's lastUsedAt telemetry even when form access is denied. Configure permissions and migrate existing data during deployment; HTTP integration and deployment verification remain separate steps.

版本与发布记录

@dani-builder/strapi-plugin-builder 共发布 30 个版本,首次发布于 2026/02/11;过去 12 个月发布了 30 个版本。

版本发布日期距今
2.5.0latest2026/11/10今天
2.4.02026/11/083 天前
2.3.02026/11/056 天前
2.2.02026/11/047 天前
2.1.02026/11/029 天前
2.0.02026/11/019 天前

关于 @dani-builder/strapi-plugin-builder 的常见问题

@dani-builder/strapi-plugin-builder 是什么?

Daniworks Builder — reusable CMS components, content types, and smart API for Strapi v5

如何安装 @dani-builder/strapi-plugin-builder?

在项目目录运行 npm install @dani-builder/strapi-plugin-builder,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^17.0.0 || ^18.0.0)、react-intl(^6.6.2)、@strapi/icons(^2.2.0)、@strapi/strapi(^5.49.0)、react-router-dom(^6.30.3)、@strapi/design-system(^2.2.0)、@strapi/plugin-color-picker(^5.0.0)、@d3levvv/strapi-react-icons-plugin(^1.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@dani-builder/strapi-plugin-builder 支持 TypeScript 吗?

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

@dani-builder/strapi-plugin-builder 支持 ESM 还是 CommonJS?

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

@dani-builder/strapi-plugin-builder 需要什么版本的 Node.js?

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

@dani-builder/strapi-plugin-builder 可以商用吗?

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

@dani-builder/strapi-plugin-builder 的下载量有多少?

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

@dani-builder/strapi-plugin-builder 还在维护吗?

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