πŸ‘€ Our most exciting product launch yet πŸš€ Join us May 8th for Sanity Connect

Adding the dashboard tool to a Sanity configuration in version 3.

10 replies
Last updated: Dec 13, 2022
Hello! I just migrated my personal website that i did with the sanity + gatsby starter, from version 2 to version 3 of sanity. All seems to be working fine, but not sure how should i add the dashboard tool to my config. Any thoughts? Thank you!
Dec 13, 2022, 5:53 PM
Can you send your config?
Dec 13, 2022, 6:40 PM
Yes:
// sanity.config.js

import { defineConfig } from "sanity";

import { deskTool } from 'sanity/desk'

import schemas from './schemas/schema'

import { visionTool } from '@sanity/vision'

import deskStructure from './src/structure/deskStructure'

import dashboard from './src/dashboardConfig'


export default defineConfig({

title: "Testing Sanity v3",

projectId: "zfgtf7ck",

dataset: "production",

plugins: [

deskTool({

structure: deskStructure

}),

visionTool(),

],

tools: (prev) *=>* {

// πŸ‘‡ Uses environment variables set by Vite in development mode

if (<http://import.meta.env.DEV|import.meta.env.DEV>) {

return prev

}

return prev.filter((tool) *=>* tool.name !== 'vision')
},
schema: {
types: schemas,
},
document: {
newDocumentOptions: (prev, { creationContext })
*=>* {
if (creationContext.type === 'global') {
return prev.filter((templateItem)
*=>* templateItem.templateId != 'siteSettings')
}
return prev
},
actions: (prev, { schemaType })
*=>* {
if (schemaType === 'siteSettings') {
return prev.filter(({ action })
*=>* !['unpublish', 'delete','duplicate'].includes(action))
}
return prev
},
},
});
Dec 13, 2022, 6:51 PM
sorry, this way its cleaner to read:
Dec 13, 2022, 6:52 PM
Shouldnt tools be inside Plugins? Currently in cellphone
Dec 13, 2022, 7:16 PM
Very true! , sorry just another question, how should i reference it?Thank you so much!
Dec 13, 2022, 7:22 PM
Reference to dashboard?
Dec 13, 2022, 7:23 PM
Yes. How should i write it in the code? so sorry im completely black in regards of how to include it.
Dec 13, 2022, 7:31 PM
You can read more about it here ! Let me know if you still stuck after reading through here
Dec 13, 2022, 7:35 PM
Omg, you legend. Thank you! I was able to solve it!
Dec 13, 2022, 8:42 PM
Congrats!
Dec 13, 2022, 8:42 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?