No document types showing in Sanity Studio at /admin route

7 replies
Last updated: Jul 31, 2023
Hello everyone, quick intro, Im User an aspiring creative technologist, have recently dabbled with nextjs and now Im starting up onto Sanity.
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
AI Update

Welcome to Sanity! The "no document types" message is a common issue when getting started, and it's usually a quick fix.

The most common cause is that your schema types aren't properly configured in your sanity.config.js (or sanity.config.ts) file. When you use defineConfig, you need to make sure you're passing your schema types correctly.

Here's what your config should look like:

import { defineConfig } from 'sanity'
import { structureTool } from 'sanity/structure'

export default defineConfig({
  name: 'my-studio',
  title: 'My Studio',
  projectId: 'your-project-id',
  dataset: 'production',
  plugins: [
    structureTool()  // This is required to see the structure tool interface
  ],
  schema: {
    types: [/* your schema types go here */]
  }
})

Common mistakes to check:

  1. Missing the schema property entirely - Make sure you have a schema: { types: [...] } object in your config

  2. Empty types array - If you haven't created any schema files yet, the types array will be empty. You need at least one document type defined

  3. Not importing your schema types - If you've created schema files (like post.js, author.js, etc.), you need to import them and add them to the types array:

import post from './schemas/post'
import author from './schemas/author'

export default defineConfig({
  // ...
  schema: {
    types: [post, author]
  }
})
  1. Missing the structureTool plugin - Without structureTool() in your plugins array, you won't see the content management interface. Note: if you're following an older tutorial, it might reference deskTool() - this has been renamed to structureTool() and the import is now import { structureTool } from 'sanity/structure'

Quick troubleshooting steps:

  • Check if you have any schema files created (usually in a schemas folder)
  • Make sure those schema files are being imported into your config
  • Verify the types array includes your imported schemas
  • Restart your dev server after making config changes
  • If the tutorial uses deskTool, replace it with structureTool and update the import path

If you're still stuck, feel free to share your sanity.config.js file and your schema folder structure - the community is always happy to help debug! Since you're at 37:18 in the tutorial, double-check that you've completed the schema creation steps that should come before that timestamp. Also note that if the tutorial is a bit older, some of the plugin names may have changed, so don't worry - the concepts are the same, just the naming has been updated.

Show original thread
7 replies
So sounds like sanity isnt picking up any definitions. In the tutorial project you can see the config file here - https://github.com/kapehe-ok/next-sanity-test/blob/main/sanity.config.ts I would check if your schema objects are coming through properly
Check your
index.ts
file to see if the schemas that you have defined are included in the
const
like here .You can then check if that
const
is included in the
sanity.config.ts
file like here .
Relevant Docs .
sanity.config.ts

_import_ { defineConfig } _from_ "sanity";

_import_ { deskTool } _from_ "sanity/desk";

_import_ schemas _from_ "./sanity/schemas/index";


const config = defineConfig({

projectId: "my-token-ID",


dataset: "production",


title: "User Sanity Next Studio",


apiVersion: "2023-07-31",


basePath: "/admin",


plugins: [deskTool()],


schemas: { types: schemas },

});


export
_default_ config;

sanity/index.ts


_import_ project _from_ "./project-schema";


const schemas = [project];


export
_default_ schemas;

@/admin[[…index]]/ page.tsx


"use client";


_import_ config _from_ "@/sanity.config";

_import_ { NextStudio } _from_ "next-sanity/studio";


export
_default_ function AdmitPage() {

_return_ <NextStudio _config_={config} />;

}
Oh and this is my project schema file

const project = {

name: "project",

title: "Projects",

type: "document",

fields: [

{

name: "name",

title: "Name",

type: "string",

},

{

name: "slug",

title: "Slug",

type: "slug",

options: { source: "name" },

},

{

name: "image",

title: "Image",

type: "image",

options: { hotspot: true },

fields: [

{

name: "alt",

title: "Alt",

type: "string",

},

],

},

{

name: "url",

title: "URL",

type: "url",

},

{

name: "content",

title: "Content",

type: "array",

of: [{ type: "block" }],

},

],

};


export
_default_ project;
Can you folks identify any problems with these as I have tried what you just mentioned, and nothing you suggested seem to make a difference. I really appreciate your help
Let’s use greetings like “Hey Everyone,” “Hi, Y’all," or “Hello, Folks” to make sure everyone in the community is included. Please read the Sanity Community Code of Conduct to stay updated on expected communication &amp; behavior in our spaces: https://www.sanity.io/docs/community-code-of-conduct
Upon starting everything fresh sanity seems to work fine. Thanks for all you efforts anyway! Have a brilliant day

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.

Was this answer helpful?