Discussion on the benefits of code-based schemas in Sanity and potential for future UI tooling
Last updated: Apr 9, 2021
I haven't used Sanity in about a year, so I set up a new project. Maybe I'm getting Sanity confused with a different product. Is there no interface to build out the content model? Is it all done programmatically?
Mar 20, 2021, 7:56 PM
yep, all done programmatically. That's actually the reason I love Sanity 😋git conflicts are a nightmare to solve when using UI that generates content model. But there's a community plugin that allows to define the schema through a model. But I can't find it.
I finished a sanity project last week and gone back to strapi to recreate it for a learning exercise and I too like the schema being code based.
Mar 21, 2021, 10:46 AM
Thanks for the feedback. I wasn't sure if I was missing something. Programmatically setting up the content model definitely has its advantages over using a UI. It's much faster, easier to share, etc. You don't have to follow a breadcrumb trail. But, there's times when I could use that visual representation or hand holding.
’s schema-inspector is a great plugin for getting "that visual representation or hand holding" you're looking for. Overall, I'd say the Sanity team opted for code-based schemas first not only because they're easier to get right and be productive, but mainly because they're more capable - take a look at custom validation patterns and you'll see you can do all sorts of fun stuff with them. Eventually, as the ecosystem matures and people find UIs more and more useful for generating schemas, we'll definitely get some tooling to generate and inspect them visually, though 🙂
Mar 30, 2021, 4:46 PM
Creating that Schema generator taught me why programmatic is better 😅 the possibilities Sanity schema give you are almost more than you could model in a UI (well not without an extreme amount of work)