
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeYes! 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:
useProjectId() - Returns the current project IDuseWorkspace() - Returns the entire workspace configuration, which includes the dataset, current user information, and other workspace settingsuseClient() - Returns a configured Sanity client instance for the current project and datasetAll 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.
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.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store