Configuration API

The Configuration API in Sanity Studio v3 is the primary mechanism that allows you to customize the studio. Because the configuration is written as plain JavaScript (or TypeScript!) it allows for composability and logic to take place in your studio’s core setup.

Workspaces

The root configuration of your studio is created by supplying either a single workspace configuration object or an array of the same type to the defineConfig-function, and returning the result as the default export of the configuration file – typically found at the root of your project in a file named sanity.config.js|ts.

// The absolute minimum viable studio configuration
import { defineConfig } from 'sanity'

export default defineConfig({
  projectId: '<project-id>',
  dataset: 'production',
})

Properties

The following table shows all the top-level properties available for configuring and customizing a single workspace studio.

Additional properties for multiple workspace-configurations

  • REQUIREDnamestring

    Name of the workspace - by convention in lowercase/camelCase

  • REQUIREDbasePathstring

    URL base path to use, for instance /myWorkspace

  • REQUIREDtitlestring

    Title of the workspace

  • subtitlestring

    Subtitle to show under the name of the workspace

  • iconReact.ComponentType

    React component to use as icon for this workspace

Examples

Minimal example

// A more plausible minmalist configuration
import { defineConfig } from 'sanity'
import { deskTool } from 'sanity/desk'
import { schemaTypes } from './schemas'


export default defineConfig({
  title: 'My cool project',
  projectId: '<project-id>',
  dataset: 'production',
  plugins: [deskTool()],
  schema: {
    types: schemaTypes,
  },
})

Multiple workspace example

import { defineConfig } from 'sanity'
import { deskTool } from 'sanity/desk'
import { visionTool } from '@sanity/vision'
import { LaunchIcon, RobotIcon } from '@sanity/icons'
import { schemaTypes } from './schemas'


export default defineConfig([
	{
	  name: 'my-prod-space',
	  title: 'My production workspace',
		icon: LaunchIcon,
	  projectId: '<project-id>',
	  dataset: 'production',
	  plugins: [deskTool()],
	  schema: {
	    types: schemaTypes,
	},
	{
	  name: 'my-staging-space',
	  title: 'My staging workspace',
		subtitle: 'The world is a stage',
		icon: RobotIcon,
	  projectId: '<project-id>',
	  dataset: 'staging',
	  plugins: [deskTool(), visionTool({ defaultApiVersion: '2022-10-21' })],
	  schema: {
	    types: schemaTypes,
	},
})

Was this article helpful?