Creating Custom Components in Slack to Avoid Drafts

2 replies
Last updated: May 21, 2023
Hey all 🙂 Can you have fields that aren’t tracked/don’t create drafts?
AI Update

No, you cannot have individual fields that don't create drafts - Sanity's draft system works at the document level, not the field level. When you edit a document in Studio, the entire document becomes a draft (with a drafts. prefix on its _id), and all fields within that document are part of the same draft version.

Your options are:

1. Use liveEdit for entire document types

You can enable live editing for specific document types by adding liveEdit: true to the schema:

export default {
  name: 'settings',
  title: 'Site Settings',
  type: 'document',
  liveEdit: true,
  fields: [
    // all fields in this document save immediately
  ]
}

With liveEdit: true, changes to that entire document type save directly to the published version without creating drafts. This is useful for configuration documents or settings where you want immediate updates.

2. Disable drafts globally

You can turn off the draft system entirely in your sanity.config.ts:

export default defineConfig({
  document: {
    drafts: {
      enabled: false
    }
  }
})

This makes all documents live-edit across your entire project.

3. Split content into separate document types

If you truly need some fields to update immediately while others go through a draft workflow, you'll need to separate them into different document types:

  • Create a pageSettings document with liveEdit: true for fields that should update immediately
  • Keep your main page document with drafts enabled for content that needs review
  • Reference the settings document from your page using a reference field

Note: The Review Changes feature does provide field-level visibility and rollback capabilities, but this is for viewing and restoring changes after they've been made - it doesn't change the fundamental behavior that drafts apply to entire documents, not individual fields.

Yep! You can create a custom component that doesn’t use the
set
function to actually write content.
Amazing thanks!

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?