Custom Block Registration
Use custom blocks when your site has its own component library and you don’t want the product’s default block set (Hero, CTA, FeatureGrid, etc.). Default blocks are a starter kit — convenient for new sites but not required. The product is content-model-agnostic: it works with any blocks you register.How it works
- You define a block manifest — an array of
BlockDefinitionobjects describing your block types - You pass it to the Content Studio API handler via
getManifest() - The AI planner, property panel, and block picker in the Content Studio all derive their behavior from your manifest
- Your site renders blocks with your own React components
Minimal example
1. Define your manifest
2. Wire into the editor API route
3. Verify
Start your dev server and check:BlockDefinition reference
propsSchema
Uses a JSON Schema subset. The product infers field types from schema + field name conventions:
| Field name pattern | Inferred type | Content Studio behavior |
|---|---|---|
*imageUrl, *Image, *logo | Image | Asset Manager modal with Unsplash, Google Drive, CMS libraries, AI generation (OpenAI or Gemini), and local upload. See Asset Manager & AI Images. |
*Alt | Image alt text | Text input |
Field with enum: [...] | Enum | Dropdown selector |
type: "number" | Number | Number input |
Everything else (type: "string") | Text | Text input, inline editable |
type: "array" with items.type: "object" | List | Repeatable item list |
*imageUrl or *Image and they’ll be detected automatically.
defaultProps
Provide sensible defaults for every field. When a user asks the AI to “add a Hero block”, these defaults are used as the starting point. The AI then modifies them based on the user’s request.
editablePaths (optional)
JSONPath-style strings hinting which fields the AI should focus on. Not required — the AI infers editability from the schema. Useful for complex blocks where you want to limit AI scope.
Image handling
If your blocks have image fields, the manifest-driven image detection handles them automatically:getManifestImageFields() utility derives this from your propsSchema — fields matching the image name pattern are included automatically.
Rendering blocks
The product doesn’t render your custom blocks — your site does. Mapblock.type to your React components:
renderBlocks() if you register renderers with the block system.
Using with a CMS
Custom blocks work with any CMS adapter. The pattern is the same as default blocks:- Fetch: Query your CMS → convert to
PageDocwithBlockInstance[] - Publish: Receive
PageDoc[]→ write back to your CMS - Image fields: Use
imageFieldsfrom your manifest (notgetImageFields()from the shared registry)
create-ai-site-editor scaffold supports custom blocks — choose “Custom blocks” when prompted and it generates a stub manifest for you to fill in.
Mixing default and custom blocks
You can use both default blocks and custom ones. ImportbuildBlockManifest() for the defaults and merge:
Checklist
- Create
lib/manifest.tswith yourBlockDefinition[] - Pass
getManifesttocreateEditorApiHandler() - Verify
/api/editor/blocksreturns your blocks - Content Studio header shows Manifest (not Degraded)
- Add block picker shows your block types
- AI can create, edit, and remove your blocks
- Image fields are detected (check publish resolves images)