
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeI can see you're getting an error when trying to add an internal link annotation to block content. The error "Could not resolve jsonType of undefined" typically occurs when there's a mismatch in how you're defining and referencing your annotation type in the schema.
Looking at your code, the issue is with how you've structured your internalLink definition. You're using type: 'reference' at the top level, but annotations need to be defined as object types with fields inside them.
Based on the Sanity documentation on annotations, here's how to fix it:
Change your internalLink definition from using type: 'reference' directly to type: 'object' with a reference field inside:
import React from 'react';
export default {
title: 'Internal link to another document',
name: 'internalLink',
type: 'object', // Changed from 'reference' to 'object'
fields: [
{
name: 'reference',
type: 'reference',
title: 'Reference',
to: [{ type: 'page' }, { type: 'route' }],
}
],
components: { // Changed from 'blockEditor' to 'components'
annotation: ({ children }) => <span>{children} 🔗</span>
}
};Then in your block content schema, reference it like this:
marks: {
annotations: [
{
name: 'internalLink',
type: 'internalLink'
}
]
}type: 'object': Annotations must be object types that can contain fields, not reference types directly at the top levelfields array: Put your reference configuration inside a field within the objectcomponents instead of blockEditor: For Studio v3, the rendering customization uses the components property with an annotation keyIf you prefer not to have a separate file, you can define the annotation directly in your block content schema:
marks: {
annotations: [
{
name: 'internalLink',
type: 'object',
title: 'Internal link',
icon: () => '🔗',
fields: [
{
name: 'reference',
type: 'reference',
to: [{ type: 'page' }, { type: 'route' }]
}
],
components: {
annotation: (props) => <span>{props.children} 🔗</span>
}
}
]
}The error you were seeing happened because the schema validator couldn't understand the structure when reference was used as the top-level type for an annotation. Wrapping it in an object type with fields resolves this issue.
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