Clarification on the necessity of the /schemas folder in a Next.js and Sanity.io integration.
You're absolutely right to be leaning towards removing that /schemas folder from your Next.js frontend! Let me clarify what's happening here.
The /schemas folder in that Next.js template exists because it's set up as an embedded studio - meaning the Sanity Studio runs directly within your Next.js application rather than as a separate deployment. This is a valid approach, but it's not what you need since you already have a separate, deployed Sanity Studio at *.sanity.studio.
In a headless CMS setup (which is what you're doing):
- Your Sanity Studio is deployed separately and manages your content schema
- Your Next.js frontend only needs to fetch data from Sanity's Content Lake using a client
- The frontend doesn't need to know about or define the schema at all
You can safely remove the /schemas folder from your Next.js project. Your frontend only needs:
- A Sanity client (usually in a
client.tsor similar file) configured with your project ID and dataset - GROQ queries to fetch the data you need
- TypeScript types (optional but recommended) - these can be auto-generated from your deployed schema using Sanity TypeGen
The tutorial you mentioned with just a client.ts file is the more common pattern for headless setups. Your Next.js app queries the Content Lake at runtime, and all schema management happens in your separate Studio deployment.
The only time you'd keep schemas in your Next.js project is if you're intentionally running an embedded studio (like for a monorepo setup where Studio and frontend live together), but that doesn't sound like your architecture.
So yes - rip it out! Your Next.js app will be cleaner and you'll avoid the confusion of maintaining duplicate schema definitions. Good instincts on this one, and congrats on the new job!
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.