
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeThe guide you're looking at uses the old import path that was updated in Sanity Studio v3! The deskTool from 'sanity/desk' was renamed to structureTool from 'sanity/structure' in v3.24.1, and this is still the current approach in Studio v4.
Here's how to properly implement a singleton document with the updated imports:
Import the correct module:
import { structureTool } from 'sanity/structure'Full configuration in sanity.config.js:
import { defineConfig } from 'sanity'
import { structureTool } from 'sanity/structure'
// Define the actions that should be available for singleton documents
const singletonActions = new Set(['publish', 'discardChanges', 'restore'])
// Define the singleton document types
const singletonTypes = new Set(['authorSettings'])
export default defineConfig({
// ... other config
plugins: [
structureTool({
structure: (S) =>
S.list()
.title('Content')
.items([
// Your singleton document
S.listItem()
.title('Author Settings')
.id('authorSettings')
.child(
S.document()
.schemaType('authorSettings')
.documentId('authorSettings')
),
// Separator
S.divider(),
// All other document types
...S.documentTypeListItems().filter(
(listItem) => !singletonTypes.has(listItem.getId())
),
]),
}),
],
schema: {
types: [
// your schema types including authorSettings
],
// Filter out singleton types from the global "New document" menu
templates: (templates) =>
templates.filter(({ schemaType }) => !singletonTypes.has(schemaType)),
},
document: {
// For singleton types, filter out actions that are not explicitly included
actions: (input, context) =>
singletonTypes.has(context.schemaType)
? input.filter(({ action }) => action && singletonActions.has(action))
: input,
},
})This configuration does three important things:
Creates a direct link to your singleton - The Structure Builder configuration creates a dedicated entry that points to a specific documentId, ensuring only one instance exists
Hides it from the "New document" menu - The schema.templates configuration prevents users from accidentally creating additional instances
Removes problematic actions - The document.actions configuration filters out actions like "duplicate" and "delete" that could cause issues with singletons
Important gotcha: Since this disables the UI for creating new instances, you should create your singleton document first before adding it to the singletonTypes set.
The key fix from the old guide is simply changing the import from deskTool and 'sanity/desk' to structureTool and 'sanity/structure'. Everything else in the singleton pattern works the same way!
If you want an even simpler approach, you can use the singleton-tools plugin which handles all of this configuration automatically.
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