Skip to content

blocks

blocks<TFieldMeta>(options): BlocksField<TFieldMeta>

Defined in: packages/core/src/fields/blocks/config.ts:101

Creates a blocks field with all defaults applied.

Validates that all block slugs are unique within this field. Each item stored in Convex carries blockType, blockName, and id in addition to the block’s own fields.

TFieldMeta extends BaseFieldMeta = BaseFieldMeta

BlocksFieldInput<TFieldMeta>

Blocks field configuration. blocks is required.

BlocksField<TFieldMeta>

Resolved blocks field definition.

If two or more block definitions share the same slug.

const heading = defineBlock({ slug: "heading", label: "Heading", fields: { text: text({ required: true }) } })
const paragraph = defineBlock({ slug: "paragraph", label: "Paragraph", fields: { content: text({ required: true }) } })
defineCollection({
fields: {
body: blocks({
label: "Body",
blocks: [heading, paragraph],
labels: { singular: "section", plural: "sections" },
}),
},
})