sanity-app-sdk
Installation
SKILL.md
Sanity App SDK
Get the maintained guide first
If the Sanity MCP server is configured, call its get_sanity_rules tool with the app-sdk rule before writing SDK code. That rule is maintained by Sanity, is more detailed, and supersedes the notes below. The notes below are a fallback for when MCP is not available.
Picking a hook
useDocuments/usePaginatedDocuments: lists of documents. Returns document handles, not full documents.useDocumentProjection: read specific fields from a handle, for display.useDocumentplususeEditDocument: read and write a single document in real time.useQuery: raw GROQ. Use sparingly; prefer handles plus projections.
Document handles
Fetch handles first, then spread them into other hooks:
const {data} = useDocuments({documentType: 'article'})