How to view fields when creating a new document schema?

31 replies
Last updated: May 4, 2021
When creating a new document schema, how can we see the fields for the first time?
AI Update

When you create a new document schema in Sanity, you'll see the fields for the first time by running your Studio locally and opening the editing interface. Here's the typical workflow:

Define Your Schema

First, create your schema using defineType in your schema files. For example:

import { defineType, defineField } from 'sanity'

export const product = defineType({
  name: 'product',
  type: 'document',
  title: 'Product',
  fields: [
    defineField({
      name: 'productName',
      type: 'string',
      title: 'Product name',
    }),
    // Additional fields...
  ],
})

Register in sanity.config.js

Add your schema type to the sanity.config.js file:

import { defineConfig } from 'sanity'
import { deskTool } from 'sanity/desk'
import { product } from './schemas/product'

export default defineConfig({
  // ... other config
  schema: {
    types: [product]
  }
})

Start the Development Server

Run the sanity dev command to start your local Studio:

npm run dev
# or
sanity dev

Your Studio will be available at http://localhost:3333 by default.

View Your Fields

Once the Studio loads, you'll see your new document type in the interface. Click on it to create a new document, and you'll see all your defined fields rendered in the Form View - the default editing interface that automatically generates form inputs based on your schema definition.

The Form View translates your schema into user-friendly input components, so each field type (string, number, image, etc.) appears with the appropriate input control. Any validation rules, descriptions, or customizations you've added to your schema will also be reflected in the interface.

Thanks to Vite-powered live reloading, any changes you make to your schema will automatically update in the browser without needing to restart the server!

Show original thread
31 replies
Are your documents visible on the left-hand side (probably under “Content”)?
Yeah the heading is
But there's no actual content because I can't see the fields to input data.
I rember I had to something like hardcoding an id or something to be able to see it for the first time
to see the empty fields I mean
(After selecting a document on the left side,) in the top-right corner of your studio, do you have a pencil and paper icon?
I do - but when I open it I don't see the new schema I added...think I missed a step.
Are you running locally (
sanity start
) and accessing via localhost:3333?
yup
I see all my document schemas except for this latest one I added.
Has it been imported and concat’d in schema.js?
Sorry, I jumped over that step before. I bet that’s what you meant by hardcoding something for the first time.
I did missed that step!
Fixing it
I need a reminder todo list of steps to take when adding a new schema
🙂
might be missing something else...
is not there yet
already deployed the schema change too
Did you run
sanity start
again (or is it still running from before)?
multiple times
Is the new schema you added of
type: 'document'
?
yes
fixed
In schema.js, did you import the file and add it down below (inside
types: schemaTypes.concat([ … ])
)?
Oh good!
I had some leftover code from a copy/paste
__experimental_actions: ['update', 'publish'],
sorry about that
Don’t be! Glad you got it working! 😄
thanks for the help 🙂

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?