Tinacms Developer Docs
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

PropertyTypeDescription
type'reference'Required.
namestringField identifier.
labelstringDisplay label in the editor.
collectionsstring[]Collection(s) to reference.
ui.collectionFilterobjectFilter available references by field values.
ui.optionComponent(props, sys) => ReactNodeCustom 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.

On this page