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

      Parameters

      • Optionalconfig: SanityConfig

        Deprecated. Formerly used to match against the instance hierarchy.

      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