
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeYes, absolutely! You can definitely do something like that in Sanity. This is a great pattern for creating reusable field definitions.
What you're showing is extracting field definitions into separate constants and then spreading them into your schema. This works perfectly in Sanity and is actually a recommended practice for keeping your schemas DRY (Don't Repeat Yourself).
Here's how you can do it:
// Define reusable fields
const title = {
name: 'title',
type: 'string',
validation: (Rule) => Rule.required().error('The title is required.'),
};
const description = {
name: 'description',
type: 'text',
validation: (Rule) => Rule.required().error('The description is required.'),
};
// Use them in your schema
export default {
name: 'Foo',
type: 'document',
fields: [title, description],
};Even better with TypeScript helpers:
If you're using TypeScript, you can use defineField for better type safety:
import {defineField, defineType} from 'sanity'
// Define reusable fields
const title = defineField({
name: 'title',
type: 'string',
validation: (Rule) => Rule.required().error('The title is required.'),
});
const description = defineField({
name: 'description',
type: 'text',
validation: (Rule) => Rule.required().error('The description is required.'),
});
// Use them in your schema
export default defineType({
name: 'Foo',
type: 'document',
fields: [title, description],
});Common use cases:
This pattern is especially useful when:
title, slug, publishedAt that appear across multiple document typesYou can even organize these in a separate file like fields.ts and import them wherever needed!
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.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store