Sanity Library Reference Docs
    Preparing search index...
    • Returns metadata for each dataset the current user has access to.

      Parameters

      • Optionaloptions: ProjectHandle<string>

        Optional project/resource to read datasets for. Defaults to the resource named in ResourceProvider/SDKProvider.

      Returns DatasetsResponse

      The metadata for your the datasets

      const datasets = useDatasets()

      return (
      <select>
      {datasets.map((dataset) => (
      <option key={dataset.name}>{dataset.name}</option>
      ))}
      </select>
      )

      The projectId is resolved in order from:

      1. an explicit projectId option
      2. A legacy ProjectContext (e.g. a <ResourceProvider projectId="…"> with no dataset), then
      3. The active resource (ResourceProvider/SDKProvider)
      4. instance.config.