Sanity Library Reference Docs
    Preparing search index...
    • Returns the currently active DocumentResource for the nearest resource context.

      Resolves in priority order:

      1. A resource prop on the nearest <ResourceProvider>
      2. The projectId/dataset from the current SanityInstance config
      3. undefined when neither is available

      Returns DocumentResource | undefined

      const resource = useResource()
      console.log(resource?.projectId, resource?.dataset)