Sanity React App SDK v2.15.0: New useCreateDocument hook and auth error recovery

This release adds a new React hook for creating documents and fixes an issue where the auth error screen would not automatically recover after a session was restored.

Create documents with useCreateDocument

The new useCreateDocument hook gives you a way to create documents directly from your Sanity SDK app. Call the hook to get a create function, then invoke it with a document handle and optional initial content.

import { useCreateDocument, createDocumentHandle } from '@sanity/sdk-react'
function CreateArticleButton() {
const createDocument = useCreateDocument()
const handleClick = () => {
const handle = createDocumentHandle({
documentId: crypto.randomUUID(),
documentType: 'article',
})
createDocument(handle, { title: 'Untitled' })
}

return New article
}

Additional options are available in the reference documentation.

🐛 Notable bugfixes and improvements

The auth error screen now automatically recovers when a session is restored, so users no longer need to manually reload after re-authenticating.