Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

Specify API version for studio client

In a previous version of the Sanity content studio, you could import a global, preconfigured Sanity client instance by importing part:@sanity/base/client.

Having a global client use a single API version is both restrictive and prevents utilizing the latest and greatest features of the Sanity API. This is why we have now deprecated using the global studio client without explicitly defining an API version to use.

Old usage:

import client from 'part:@sanity/base/client'

client.fetch('*[_type == "author"][0...10]')

New usage:

import sanityClient from 'part:@sanity/base/client'

const client = sanityClient.withConfig({apiVersion: '2021-06-07'})

client.fetch('*[_type == "author"][0...10]')

Details about getting your versioned client set up can be found under API Versioning and the JavaScript Client.

Was this article helpful?