Sanity project missing schema.js file after installation with clean template

32 replies
Last updated: Nov 29, 2025
I've started multiple times from the tips on the sanity page which is to create a project like this but it still installs without a schema.js file:
npm create sanity@latest -- --template clean --create-project "Sanity Project" --dataset production

AI Update

This is actually expected behavior for the clean template! The --template clean option is specifically designed to create a Sanity project without predefined schemas, giving you a blank slate to start from.

When you run:

npm create sanity@latest -- --template clean --create-project "Sanity Project" --dataset production

You'll get a project structure with a schemaTypes folder that contains only an index.ts file with an empty array:

// src/schemaTypes/index.ts
export const schemaTypes = []

This is intentional! The clean template is meant for developers who want to build their schema from scratch without any example content types.

What you should do next

You now need to create your own schema types. Here's how to add your first one:

  1. Create a new schema file in src/schemaTypes/, for example postType.ts:
// src/schemaTypes/postType.ts
import {defineField, defineType} from 'sanity'

export const postType = defineType({
  name: 'post',
  title: 'Post',
  type: 'document',
  fields: [
    defineField({
      name: 'title',
      type: 'string',
    }),
  ],
})
  1. Register it in your schema types index:
// src/schemaTypes/index.ts
import {postType} from './postType'

export const schemaTypes = [postType]

About schema.js vs schemaTypes/index.ts

There is no schema.js file in modern Sanity projects because:

  • Current Sanity Studio (v3+) uses TypeScript by default
  • Schemas are defined in the schemaTypes folder with an index.ts file
  • This is the modern approach documented in the opinionated guide to Sanity Studio

If you want example schemas instead

If you'd prefer to start with pre-built example schemas to learn from, use the blog template instead:

npm create sanity@latest -- --template blog

This will give you a complete blog setup with example document types like post, author, and category that you can learn from and modify.

The clean template is working exactly as designed - it provides the basic project structure but leaves all schema definition up to you!

Show original thread
32 replies

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?