
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeIn Sanity Studio v3, withDocument from part:@sanity/form-builder has been replaced by the useFormValue hook. The parts system was completely removed in v3, so you'll need to refactor your custom input components to use hooks instead.
Here's how to migrate:
Old v2 pattern:
import { withDocument } from 'part:@sanity/form-builder';
const MyCustomInput = withDocument(({ document, type, value, onChange }) => {
// Access document here
console.log(document)
return <input ... />
})New v3 pattern:
import { useFormValue } from 'sanity'
const MyCustomInput = (props) => {
// Get the entire document with an empty array
const document = useFormValue([])
// Or get specific fields
const title = useFormValue(['title'])
const authorId = useFormValue(['author', '_ref'])
return <input ... />
}Key differences:
useFormValue([]) with an empty array to get the complete document object, equivalent to what withDocument provided['fieldName'] for top-level fields or ['parent', 'child'] for nested fieldsThe useFormValue hook only works within the form builder context (inside custom input components). If you need document data in other contexts like document actions, you'll need to use different approaches like the useDocumentOperation hook or fetch data via the Sanity client.
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