
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeGreat question! Yes, in Sanity Studio v3, accessing document data in custom input components works differently than in v2. The document is no longer passed directly as props, but you can access it using the useFormValue hook.
To access the entire document in your custom input component:
import { useFormValue } from 'sanity'
const MyCustomInput = (props) => {
const document = useFormValue([]) // Empty array returns entire document
// Now you can access any field from the document
console.log(document._id, document.title, etc.)
return (
// your component JSX
)
}You can also access specific fields or parent information by passing a path array:
// Access a specific field
const title = useFormValue(['title'])
// Access nested fields
const authorName = useFormValue(['author', 'name'])
// Access document ID
const docId = useFormValue(['_id'])
// Access parent field (if your input is nested)
const { path } = props
const parentPath = path.slice(0, -1)
const parentValue = useFormValue(parentPath)Here's a practical example where one field depends on another:
import { useFormValue } from 'sanity'
const DynamicListInput = (props) => {
const categoryId = useFormValue(['category']) // Access sibling field
const [options, setOptions] = useState([])
useEffect(() => {
if (categoryId) {
// Fetch options based on category
fetchOptions(categoryId).then(setOptions)
}
}, [categoryId])
return props.renderDefault({
...props,
schemaType: {
...props.schemaType,
options: { list: options }
}
})
}useFormValue hook only works within the form builder context (i.e., in custom input components). You can't use it in document actions or other contexts outside the form.props.document and props.parent patterns from v2.The migration guide you mentioned should cover this, but the key takeaway is: use useFormValue instead of accessing document data through props.
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