No document types showing in Sanity Studio at /admin route
I have been following this tutorial -
https://www.youtube.com/watch?v=OcTPaUfay5I&t=2363s I have followed all the steps up to 37:18 and when I navigate to localhost:3000/admin, it says I have no document types
Any clue how I can solve this problem, happy to share code with whoever is willing to help.
Big thanks in advance. Sorry in advance for coding newbie-ness
The config key is wrong. defineConfig reads schema types from schema (singular), not schemas. Under schemas: { types: ... } Studio receives no types and shows "no document types". Rename the key to schema.
// sanity.config.ts
'use client'
import { defineConfig } from 'sanity'
import { structureTool } from 'sanity/structure'
import schemas from './sanity/schemas'
export default defineConfig({
projectId: 'your-project-id',
dataset: 'production',
title: 'My Studio',
basePath: '/admin', // must match the route Studio is mounted on
plugins: [structureTool()],
schema: {
types: schemas, // an array of your schema types, e.g. [project]
},
})The defineConfig reference lists schema as an object with a types array and optional templates. The schema property isn't required, but few Studio features work without it, and there's no schemas property.
Other things to check
Your schema index exports an array. For example:
// sanity/schemas/index.ts import project from './project-schema' const schemas = [project] export default schemasMake sure the import path in
sanity.config.tspoints to this file.Use
structureToolinstead ofdeskTool. Older tutorials usedeskToolfromsanity/desk. Since Studio v3.24.1 it'sstructureToolfromsanity/structure. The old name still works as a deprecated alias, butsanity/deskimports will be removed in a later major version. To update your code automatically, commit your changes first, then runnpx @sanity/cli@latest codemod deskRenamein the Studio root (Desk is now Structure).Embedded Studio setup in Next.js (Embed Sanity Studio in Next.js):
- Put
'use client'at the top ofsanity.config.ts. Without it, Next.js renders the config on the server and you get a blank page or a hydration error. basePathmust equal the actual route. For/admin, usebasePath: '/admin'and an optional catch-all route such asapp/admin/[[...tool]]/page.tsx:
import { NextStudio } from 'next-sanity/studio' import config from '../../../sanity.config' // adjust to your folder depth export const dynamic = 'force-static' export { metadata, viewport } from 'next-sanity/studio' export default function StudioPage() { return <NextStudio config={config} /> }Starting from scratch. Running
npx sanity@latest initinside a Next.js project detects Next.js. It asks for a Studio route and createssanity.config.ts,sanity.cli.tsand the route file for you, which avoids typos like this one.
Once schema.types contains your project type, "Projects" appears in the Structure tool.
Show original thread7 replies
Was this answer helpful?
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.