
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeYou're actually using the correct, standard approach for references in Sanity! The pattern you described—a single reference type with multiple document types in the to array—is exactly what the official documentation recommends:
{
title: 'Directors',
name: 'directors',
type: 'array',
of: [
{
type: 'reference',
to: [
{type: 'person'},
{type: 'company'},
// ... all your other types
]
}
]
}The schema-array-of-invalid error you encountered likely happened if you tried creating multiple separate reference objects with different name properties in the array's of property. While technically possible, that's an unconventional pattern and not what the docs demonstrate.
For your usability problem (hundreds of documents making it hard to find what you want), here are some better solutions:
filter to constrain the reference pickerYou can add filters to narrow down what appears in the reference picker based on document properties:
{
type: 'array',
name: 'items',
of: [{
type: 'reference',
to: [
{type: 'typeA'},
{type: 'typeB'},
// ... dozens more
],
options: {
filter: '_type == $selectedType',
filterParams: {selectedType: 'typeA'} // Could be dynamic
}
}]
}You can create a custom input component that lets editors first select which document type they want to reference, then shows only documents of that type.
disableNew if neededIf you don't want inline document creation cluttering the UI:
options: {
disableNew: true
}Yes, a reference with many types in to will generate larger queries, but that's just how references work. The query needs to handle all possible types. You can optimize your frontend queries by only dereferencing the fields you actually need:
*[_type == "yourDoc"] {
items[]-> {
_type,
// only the fields you need, not everything
title,
slug
}
}The error message you hit was likely because of a schema syntax issue (maybe duplicate names or incorrect nesting), not because Sanity limits the number of types in a reference. If you share the specific error or schema structure, I can help debug further!
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store