Index
Edit

sanity.json

sanity.json is a configuration file for Sanity components. There's one in the root of your project that contains the basic configuration for your studio.

Here's an example:

{
  "root": true,
  "project": {
    "name": "Movies",
    "basePath": "/studio"
  },
  "api": {
    "projectId": "<yourProjectID>",
    "dataset": "production"
  },
  "plugins": [
    "@sanity/base",
    "@sanity/components",
    "@sanity/default-layout",
    "@sanity/default-login",
    "@sanity/desk-tool",
    "@sanity/google-maps-input"
  ],
  "parts": [
    {
      "name": "part:@sanity/base/schema",
      "path": "./schemas/schema.js"
    }
  ]
}

If you want to target different datasets in your local development environment and on the remote production you can configure sanity.json like this:

{
  //...,
  "api": {
    "projectId": "<yourProjectId>",
    "dataset": "production"
  },
  "env": {
    "development": {
      "api": {
        "dataset": "staging"
      }
    }
  },
  //...
}

Here is a short explanation for each key:

  • root defines whether this is the root sanity.json file of your project. Plugins also has a sanity.json configuration file that defines their named parts, but plugins should have the root property set to false (or omitted entirely).
  • project defines the name of the studio displayed to the user. Optionally is may also contain a basePath that defines the root path for the studio. This lets you build the studio to a static bundle with sanity build and embed it in existing management interfaces.
  • api defines the projectId and dataset that this content studio will be connected to. You can find the projectId on sanity.io/manage when looking at your project. A project can have multiple datasets so you need to configure that as well.
  • plugins defines the basic plugins for your studio. These plugins may themselves define their own plugins with their own sanity.json files. If you want to provide your own implementations for any of these you may do so below under parts.
  • parts defines named parts for the plugin system. In this example, we only define a single part – our schema that define the data model for this studio.

Previous: Project StructureNext: Localization