Joint session with Vercel: How to build intelligent storefronts (May 15th) →

How to read/display current dataset in Sanity Studio?

3 repliesLast updated: Nov 29, 2025

Hi all. I would like to read and display the current dataset being loaded on the desk. Is there a way to read the current dataset?
AI Update

Yes! There are several hooks available to read the current dataset being loaded in the Sanity Studio desk. The most direct way is to use the useDataset() hook.

Here's a simple example of how to use it:

import { useDataset } from 'sanity'

export function MyComponent() {
  const dataset = useDataset()
  
  return (
    <div>Current dataset: {dataset}</div>
  )
}

The useDataset() hook returns the name of the current dataset as a string. This is particularly useful when you need to:

If you need more information beyond just the dataset name, you might also find these related hooks helpful:

All of these hooks are available from the 'sanity' package and can be used in any custom React component within your Studio.

You can find more details about these hooks in the Studio React Hooks documentation.

Show original thread
3 replies

Was this answer helpful?

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Related contributions