Sanity Library Reference Docs
    Preparing search index...
    • Retrieves the current Sanity instance from context

      Returns SanityInstance

      The current Sanity instance

      This hook accesses the nearest Sanity instance from the React context. The hook must be used within a component wrapped by a ResourceProvider or SanityApp.

      const instance = useSanityInstance()
      console.log(instance.config.projectId)

      Error if no SanityInstance is found in context