Sanity Studio: "Loading document..." indefinitely with custom structure builder
Based on the warning message you're seeing, the issue is clear: Sanity now requires the schemaType parameter when using S.document() in the Structure Builder, and this is becoming a mandatory requirement.
The warning tells you exactly what's missing:
Structure warning: document type (schemaType) will be required for document nodes in the near future!
Your current code creates document nodes without specifying the schema type:
.child((documentId) =>
S.document()
.documentId(documentId)
.views(Views({ type: "productPage" }))
)The fix is simple β add .schemaType('productPage') to your document node:
S.listItem()
.title("Product Pages")
.id("productPages")
.icon(Icon)
.child(
S.documentTypeList("productPage")
.title("Product Pages")
.menuItems(S.documentTypeList("productPage").getMenuItems())
.filter("_type == $type")
.params({ type: "productPage" })
.child((documentId) =>
S.document()
.documentId(documentId)
.schemaType('productPage') // <-- Add this line
.views(Views({ type: "productPage" }))
)
)The reason it works when you use S.documentTypeListItems() is because that convenience method automatically handles the schema type association for you. When you build custom structures with S.document(), you need to explicitly specify it.
This change is part of Sanity's move toward more explicit structure definitions, which helps improve type safety and makes the structure configuration more predictable. The Structure Builder documentation shows examples using .schemaType() for document nodes.
The "indefinite loading" happens because without the schema type, Studio can't properly resolve which document schema to use for rendering the document, causing the loading state to hang.
Show original thread8 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.