Invalid item type" error with blockContent schema in Sanity array
I understand this error is frustrating! Looking at your schema, the structure actually appears correct - the image block definition {type: 'image', options: {hotspot: true}} is perfectly valid according to the image type documentation. You don't need to add a name property for items in the of array.
The "Invalid item type: '[object Object]'" error typically occurs due to schema loading or import issues rather than the schema definition itself. Here are the most likely causes:
1. Schema not properly imported/registered
The most common cause is that your blockContent schema isn't being imported correctly into your main schema configuration. Make sure you're registering it properly in your sanity.config.ts (or schema.js for older setups):
import blockContent from './blockContent'
export default defineConfig({
// ... other config
schema: {
types: [blockContent, /* other types */]
}
})2. Schema cache issues
Sometimes the Studio caches a broken schema state. Try:
- Stop your dev server
- Delete the
.sanityfolder in your project root (if it exists) - Run
sanity startagain (ornpm run dev)
3. Circular dependencies or duplicate type names
Check that:
- You don't have another schema type also named
blockContent - Your import paths are correct and not creating circular references
4. Using older Sanity version syntax
If you're on Sanity Studio v3+, consider using the newer defineType and defineField helpers for better type safety:
import {defineType, defineField, defineArrayMember} from 'sanity'
export default defineType({
title: 'Block Content',
name: 'blockContent',
type: 'array',
of: [
defineArrayMember({
title: 'Block',
type: 'block',
styles: [
{title: 'Normal', value: 'normal'},
{title: 'H1', value: 'h1'},
{title: 'H2', value: 'h2'},
{title: 'H3', value: 'h3'},
{title: 'H4', value: 'h4'},
{title: 'Quote', value: 'blockquote'},
],
lists: [{title: 'Bullet', value: 'bullet'}],
marks: {
decorators: [
{title: 'Strong', value: 'strong'},
{title: 'Emphasis', value: 'em'},
],
annotations: [
{
title: 'URL',
name: 'link',
type: 'object',
fields: [
{
title: 'URL',
name: 'href',
type: 'url',
},
],
},
],
},
}),
defineArrayMember({
type: 'image',
options: {hotspot: true},
}),
],
})To debug further:
Try temporarily simplifying your schema to isolate the issue:
export default {
name: 'blockContent',
type: 'array',
of: [{type: 'block'}]
}If this works, gradually add back the other configurations (styles, marks, annotations, image) one at a time to identify what's causing the problem.
The error message suggests Sanity is receiving a plain JavaScript object where it expects a properly defined type, which usually points to an import/export issue or schema registration problem rather than the schema structure itself.
Show original thread6 replies
Sanity – Build the way you think, not the way your CMS thinks
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.