Reference
2 min read

Special Use Cases for Comments

Learn how to use and manage Comments in uncommon cases, like enabling and disabling comments for individual branches, using a CSP, and more.
Table of Contents

Using the project settings menu is not the only way to enable or disable comments. This section teaches you how to toggle comments on or off for branches, enable them project-wide with environment variables, and more.

Enabling comments project-wide opens a new communication channel that could disrupt your current feedback and iteration workflow. Enabling or disabling comments on specific branches allows you to take advantage of comments while controlling when this new style of collaboration is possible.

Vercel allows you to set Preview environment variables, which can be scoped to individual branches or to all branches which generate previews.

To enable comments for an individual branch, add the following to the environment variables for the desired preview branch:

.env
VERCEL_PREVIEW_FEEDBACK_ENABLED=1

To disable comment for an individual branch, set the above environment variable's value to 0:

.env
VERCEL_PREVIEW_FEEDBACK_ENABLED=0

You can enable or disable comments project-wide with project environment variables. Navigate to your project's environment variables in your Vercel dashboard and add the VERCEL_PREVIEW_FEEDBACK_ENABLED variable.

Set its value to 1 if you want it enabled, or 0 if you want it disabled.

To disable comments temporarily, see the Disable toolbar for session section of the toolbar documentation.

Commenting is not currently supported on main or master branches. To use comments, you must open a pull request on a branch in your favorite Git provider.

If you have a Content Security Policy (CSP) configured, you may need to adjust the CSP to enable access to Comments.

You can make the following adjustments to the Content-Security-Policy response header:

  • Add the following to script-src (Most commonly used):
  script-src https://vercel.live
  • Add the following to connect-src:
  connect-src https://vercel.live wss://ws-us3.pusher.com
  • Add the following to img-src:
  img-src https://vercel.live https://vercel.com data: blob:
  • Add the following to frame-src:
  frame-src https://vercel.live
  • Add the following to style-src:
  style-src https://vercel.live 'unsafe-inline'
  • Add the following to font-src:
  font-src https://vercel.live https://assets.vercel.com

To use comments with preview deployments that have custom alias domains, you must opt into comments explicitly in your project settings on the dashboard.

See our docs on enabling comments to learn more.

Comments are available in all preview deployments on Vercel. To enable comments in production deployments and localhost, you must add the Vercel toolbar to your project with our @vercel/toolbar package, or with our injection script.

See the using in production or local environments for more information.

Last updated on May 29, 2024