Error when creating new document type in Desk tool
Based on the error you're describing, the Desk tool crash when creating a new document typically indicates a schema configuration issue. Since you mentioned you just created a new document type, here are the most common causes and solutions:
Common Causes
1. Missing Required Properties
Every document type needs at minimum a name and type property. Make sure your schema definition includes both:
defineType({
name: 'yourDocumentType',
type: 'document',
// ... other properties
})2. Invalid Field Definitions
Fields within your document also need proper name and type properties. According to Sanity's schema documentation, you should always use the defineField helper:
fields: [
defineField({
name: 'title',
type: 'string',
title: 'Title'
})
]3. Circular References or Invalid Types If you're referencing other document types or using custom types, make sure they're properly defined and don't create circular dependencies.
4. Validation Rules Errors If you've added validation rules, syntax errors in those functions can crash the Studio:
validation: (rule) => rule.required() // Make sure this is properly formattedDebugging Steps
Check the browser console - Open your browser's developer tools and look for more specific error messages that will point to the exact line causing the issue
Temporarily simplify the schema - Comment out all fields except the bare minimum to see if the document type itself is the problem:
defineType({
name: 'yourDocumentType',
type: 'document',
fields: [
defineField({
name: 'title',
type: 'string'
})
]
})- Verify your imports - Make sure you're importing
defineTypeanddefineFieldfrom the correct package:
import { defineType, defineField } from 'sanity'Check for typos - Common mistakes include misspelling property names like
fieldvsfields, or using incorrect type namesLook for JavaScript syntax errors - Missing commas, unclosed brackets, or improper function syntax in validation rules or custom components
When you share the code you mentioned, look specifically for:
- Any unusual syntax in your field definitions
- Custom components that might be throwing errors
- Validation functions with improper syntax
- Missing or extra commas/brackets
The browser console error will usually point to the exact line and property causing the crash, which will help narrow down the issue quickly!
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.