defineConfig
Defines the configuration for Sanity Studio. This is the primary function used in yoursanity.config.ts file to configure your studio instance.
Function Signature
defineConfig function accepts a configuration object and returns it with proper TypeScript typing. It’s a type-helper function that provides autocompletion and type-checking for your studio configuration.
Parameters
The name of the workspace. Required when using multiple workspaces. For single workspace configurations, this is optional.
The title of the studio displayed in the UI.
Your Sanity project ID. Find this in your project settings at sanity.io/manage.
The dataset name to use for this studio instance.
URL base path for the studio, for instance
/studio. Note this is a client-side routing feature. For serving your studio from a subpath, use the basePath property in sanity.cli.ts.Array of plugins to enable in the studio. Plugins extend studio functionality and can provide tools, schema types, document actions, and more.
Top-level tools available in the studio. Tools are React components rendered when active, with a URL route, title, name, and icon. Examples include the Structure tool and Vision tool.
Document-level configuration.
Document actions available in the document editor (e.g., publish, delete).
Badges displayed on documents to indicate status.
Controls which document types appear in the “Create new” dialog.
Function to resolve the production URL for a document.
Form-level configuration.
Custom form components to override default inputs, fields, and previews.
File field configuration (same structure as
form.image).React component to use as the workspace icon.
Custom theme configuration for the studio.
API hostname for requests. Used for custom CNAMEs. Must include protocol (e.g.,
https://sanityapi.mycompany.com).Authentication configuration for the studio.
Return Value
Returns the configuration object with proper TypeScript typing.
Example
Single Workspace
Multiple Workspaces
With Custom Form Configuration
Source Location
packages/sanity/src/core/config/defineConfig.ts:6
Related
- definePlugin - Define a plugin for Sanity Studio
- defineType - Define a schema type