
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeYes, what you're looking for is called a singleton document in Sanity. This is exactly designed for use cases like company settings, homepage content, or any other content that should only have one instance.
To properly set up a singleton document, you need to configure three things in your sanity.config.js file:
First, define which types should be singletons and customize your structure:
import { defineConfig } from 'sanity'
import { structureTool } from 'sanity/structure'
const singletonTypes = new Set(['settings', 'homepage'])
export default defineConfig({
// ... other config
plugins: [
structureTool({
structure: (S) =>
S.list()
.title('Content')
.items([
// Singleton for settings
S.listItem()
.title('Settings')
.id('settings')
.child(
S.document()
.schemaType('settings')
.documentId('settings')
),
// Singleton for homepage
S.listItem()
.title('Homepage')
.id('homepage')
.child(
S.document()
.schemaType('homepage')
.documentId('homepage')
),
// ... other document types
...S.documentTypeListItems()
.filter((listItem) => !singletonTypes.has(listItem.getId()))
])
})
]
})export default defineConfig({
// ... other config
schema: {
types: [/* your schemas */],
templates: (templates) =>
templates.filter(({ schemaType }) => !singletonTypes.has(schemaType))
}
})const singletonActions = new Set(['publish', 'discardChanges', 'restore'])
export default defineConfig({
// ... other config
document: {
actions: (input, context) =>
singletonTypes.has(context.schemaType)
? input.filter(({ action }) => action && singletonActions.has(action))
: input
}
})You need to create the document instance first before adding it to the singletonTypes set. Otherwise, you won't have a way to create it through the UI.
If you want to skip the manual configuration, you can use the singleton-tools plugin which handles all of this automatically.
Your schema for something like company settings would look like a normal document schema:
export default {
name: 'settings',
title: 'Settings',
type: 'document',
fields: [
{
name: 'companyLogo',
title: 'Company Logo',
type: 'image'
},
{
name: 'companyAddress',
title: 'Company Address',
type: 'text'
}
]
}The singleton configuration just controls how it appears in the Studio interface - as a single object rather than a list you can add to! You can find the full guide on setting up singleton documents in the Sanity documentation.
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