Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sanity IO CMS - What is the difference between sanity.config.js and sanity.json

Working with a Version 3 Sanity project to provide backend data.

However, I noticed that there are two files that deals with project settings/configurations.

  1. PROJECT_DIR/sanity.config.js - included from startup
  2. PROJECT_DIR/sanity.json - not included from startup

My question are

  1. What is the difference between the two
  2. How should I handle duplicate settings such as plugins that are already defined in sanity.config.js, do I define them again in sanity.json?

Please help, as I cannot find any documentation that addresses my questions above,

An example taken from sanity docs sanity.json

{
  "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"
    }
  ]
}

And an example from my project sanity.config.js

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

export default defineConfig({
  name: 'default',
  title: 'app-title',

  projectId: '<project-id>',
  dataset: 'production',

  plugins: [deskTool(), visionTool()],

  schema: {
    types: schemaTypes,
  },
})

Would I still include "@sanity/desk-tool" in my sanity.json if deskTool() is already added within the plugins array in sanity.config.js

like image 527
0x5929 Avatar asked Dec 29 '25 04:12

0x5929


1 Answers

The JSON-based configuration in sanity.json file has been deprecated on Sanity v3 in favor of sanity.config.js file, this is one of their breaking changes. See docs for reference. In other words, if you're using Sanity v3, don't include sanity.json, handle all the configs that were previously in that file on sanity.config.js.

like image 167
ivanatias Avatar answered Dec 31 '25 16:12

ivanatias