Can you reference a document in draft mode when creating a new document?
Yes! You can absolutely reference documents in draft mode from other draft documents using weak references. This is exactly the use case weak references were designed for.
By default, Sanity uses "strong" references that only point to published documents. When you try to reference a draft document with a standard reference, you'll get validation errors on auto-save because the published version doesn't exist yet.
The Solution: Add weak: true to Your Reference Field
In your schema definition, modify your reference field to include weak: true:
{
name: 'parentPage',
type: 'reference',
to: [{type: 'page'}],
weak: true // This allows referencing draft documents
}This tells Sanity that the reference doesn't need to point to a published document, so you can reference drafts without errors.
How It Works
- Strong references (default) require the referenced document to be published and enforce referential integrity
- Weak references allow you to reference documents regardless of their publication status—draft, published, or even non-existent
This is perfect for your sub-page/parent structure where you want to create child pages that reference a parent page that's still in draft mode.
Important Notes
For Programmatic Creation
If you're creating documents through mutations or the client API, use _weak (with an underscore) instead:
{
_type: 'reference',
_ref: 'parent-document-id',
_weak: true
}For Initial Values
When setting initial values that include references to drafts, make sure to include _weak: true in the reference object.
Querying Considerations
When querying with GROQ, the standard -> dereferencing operator only fetches published documents. If you need to retrieve draft versions of weakly-referenced documents, you may need to write custom queries that handle both drafts.* and published IDs.
Weak references give you the workflow flexibility to build interconnected content structures without forcing a specific publishing order, which is exactly what you need for your parent/sub-page hierarchy! You can read more about this in the Sanity reference type documentation.
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.