Upgrading to v3 and splitting desk structure causes crashes in Sanity Studio
Your code structure looks correct - you're following the same modular pattern used in the Hydrogen starter. However, the crash you're experiencing when editing home.js isn't documented as expected behavior, and this appears to be a potential bug worth investigating.
Your setup follows best practices:
Your approach of splitting structure files is valid according to the Structure Builder documentation. The pattern you're using - exporting functions that accept the Structure Builder (S) parameter and composing them together - is the correct way to organize structure code:
// desk/home.js
export const home = (S) =>
S.listItem()
.title('Home')
.icon(HouseLine)
.child(
S.editor()
.title('Home Page')
.schemaType('homePage')
.documentId('homePage')
)
// desk/index.js
import { home } from './home'
export const structure = (S) =>
S.list()
.title('Content')
.items([
home(S),
...S.documentTypeListItems().filter(hiddenDocTypes)
])This matches the recommended patterns from the Structure Builder guide.
Troubleshooting steps:
Since crashes on file changes aren't documented behavior, try these approaches:
Check your Studio version - Make sure you're on the latest Studio v3 release. Run
npm list sanityto check your version, and consider updating if you're not on the latest.Look for console errors - When the crash happens, check your browser console and terminal for specific error messages. These will be helpful when reporting the issue.
Verify your imports - Ensure there are no circular dependencies between your structure files and that all imports resolve correctly.
Test with minimal configuration - Temporarily simplify your
home.jsto rule out issues with the icon import or specific Structure Builder methods:
export const home = (S) =>
S.listItem()
.title('Home')
.child(S.documentTypeList('homePage'))- Try manual refresh - As a temporary workaround while developing, you might need to manually refresh the browser after saving structure file changes rather than relying on hot module reload.
Report this issue:
Since this behavior isn't documented and your code follows established patterns, I'd recommend reporting this:
- Post in the Sanity Community Slack with your specific error messages and Studio version
- Open a GitHub issue on the sanity repository with steps to reproduce
Include details like your Studio version, Node version, and the exact error messages you're seeing. The Sanity team can then determine if this is a bug with hot module reloading when structure files are split across modules, or if there's a specific configuration issue causing the problem.
Your code organization is solid - the issue appears to be with how the development server handles these particular file updates, not with your structure implementation.
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.