Fields
Reference Field
Link documents across collections
Links a document to another document in a different collection. Useful for relationships like posts → authors, products → categories, etc.
Usage
{
type: 'reference',
name: 'author',
label: 'Author',
collections: ['author'],
}Options
| Property | Type | Description |
|---|---|---|
type | 'reference' | Required. |
name | string | Field identifier. |
label | string | Display label in the editor. |
collections | string[] | Collection(s) to reference. |
ui.collectionFilter | object | Filter available references by field values. |
ui.optionComponent | (props, sys) => ReactNode | Custom rendering for reference options. |
Type Signature
interface ReferenceField {
type: 'reference'
name: string
label?: string
collections: string[]
ui?: {
collectionFilter?: Record<string, Record<string, string | string[]>>
optionComponent?: (props: unknown, sys: { path: string }) => ReactNode
}
}Examples
Multiple Collections
Reference documents from multiple collections:
{
type: 'reference',
name: 'related',
label: 'Related Content',
collections: ['post', 'author'],
}Filtered References
Only show authors from a specific location:
{
type: 'reference',
name: 'author',
label: 'Author',
collections: ['author'],
ui: {
collectionFilter: {
author: { location: 'Australia' },
},
},
}Multiple Filter Values
{
type: 'reference',
name: 'author',
label: 'Author',
collections: ['author'],
ui: {
collectionFilter: {
author: { location: ['Australia', 'United States'] },
},
},
}Large Collections
If referencing a collection with many items, you may hit timeout issues. Use collectionFilter to reduce the list.