
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeIn Sanity Studio v3, the Parts System has been completely replaced, so you can no longer use import client from "part:@sanity/base/client". Instead, you have a few modern approaches to get your dataset configuration:
The most common approach in v3 is to use the useClient hook within React components:
import { useClient } from 'sanity'
function MyComponent() {
const client = useClient({ apiVersion: '2023-05-24' })
const dataset = client.config().dataset
// Use dataset...
}Important: Since useClient is a React hook, it must be called inside a React component or custom hook - you can't use it at the module level.
If you need to access the dataset outside of a React component (like in a utility file), you can import your configuration directly:
import { dataset } from './sanity.config'
// Use dataset...Your sanity.config.ts (or .js) file should export your configuration:
import { defineConfig } from 'sanity'
export default defineConfig({
projectId: 'your-project-id',
dataset: 'production',
// ... other config
})
// You can also export individual values
export const { dataset, projectId } = defineConfig({
projectId: 'your-project-id',
dataset: 'production',
})If you're building with the App SDK, import from @sanity/sdk-react instead:
import { useClient } from '@sanity/sdk-react'
const client = useClient({ apiVersion: '2023-05-24' })
const dataset = client.config().datasetThe v3 migration removed the old parts-based import system in favor of standard JavaScript imports and React hooks, which provides better TypeScript support and a more modern development experience.
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