👀 Our most exciting product launch yet 🚀 Join us May 8th for Sanity Connect
Experimental feature

Enable and configure Comments

Learn how to enable and configure the Comments feature in Sanity Studio.

Comments are available as an opt-out beta feature for all paid plans in Sanity Studio. This article walks studio maintainers through enabling and configuring comments for their projects.

Paid feature

This article discusses a feature that is available for projects on the Growth plan and up. Visit our pricing page to learn about Sanity's different plan offerings.

Prerequisites:

  • Sanity Studio v3.32.0 or later (latest is always recommended)
  • Project on a supported plan

Enabling and disabling comments

Comments are enabled by default for all paid plans. To disable comments, set document.unstable_comments.enabled to false in your studio configuration file:

// ./sanity.config.ts|js

export default defineConfig({
  // ... rest of config
  document: {
    unstable_comments: {
      enabled: false,
    },
  },
});

Gotcha

Disabling comments hides them in the studio, but existing comments persist in the add-on comment dataset.

Enabling comments for specific document types

To enable comments only for specific document types, use an arrow function:

// ./sanity.config.ts|js

export default defineConfig({
  // ... rest of config
  document: {
    unstable_comments: {
      enabled: (ctx) => {
        return ctx.documentType == 'whitepaper';
      },
    },
  },
});

To enable comments for multiple document types, use an array:

// ./sanity.config.ts|js
const COMMENTS_ENABLED = ['article', 'blog', 'whitepaper'];

export default defineConfig({
  // ... rest of config
  document: {
    unstable_comments: {
      enabled: (ctx) => {
        return COMMENTS_ENABLED.includes(ctx.documentType);
      },
    },
  },
});

Where are comments stored?

To keep everything neat and tidy, comments are stored parallel to your content in a complimentary dataset, along with other workflow and collaboration data, such as Comments.

These datasets:

  • Do not count toward the data limit of your current plan.
  • Do not incur any extra costs for your project.
  • Are listed in the project management pages under Datasets, along with all existing datasets for a project.
  • Include a distinctive suffix in the dataset name. This is a best-effort attempt, and the result may vary, depending on the character length of the name of the related document dataset. Examples:
    • <related-document-dataset>-comments
    • <related-document-dataset>-cmts
    • <related-document-dataset>-cmt
    • <related-document-dataset>-c
  • Are searchable: you can query comment datasets with GROQ or GraphQL. This means they can also be used with GROQ-powered Webhooks.

Gotcha

Deleting an add-on comment dataset permanently removes all comments. To restore commenting after deletion, reload the studio instance to create a new, empty comment dataset.

Was this article helpful?