Skip to content
Commmenty
DocsAdd the script

Add the script

People can comment on a prototype only once it has Commmenty's script. The script lets Commmenty show the prototype in its viewer and pin comments to its elements.

Copy it

New prototype shows the script in its first step. For a prototype you already created, it is in the prototype's page, under Setup. The script looks like this, with your own key:

<script src="https://app.commmenty.com/embed.js"
        data-pf-origin="https://app.commmenty.com"
        data-pf-key="ak_…"></script>

Copy for AI has three options:

  • Copy prompt: instructions for a coding agent, such as Claude Code. Paste them in a session opened in the prototype's repo; the agent finds the stack, adds the script and checks that each screen has its own URL.
  • Copy snippet: the script tag alone.
  • Show manual setup: the steps below.

Where it goes

Add the tag once, on every page, and load it from app.commmenty.com. Don't keep a local copy of embed.js.

StackWhere
Plain HTMLJust before </body> on every page.
Vite, Create React App or another single-page appIn index.html, just before </body>.
Next.js, App RouterIn app/layout.tsx, inside <body>, with next/script and strategy="afterInteractive".
Next.js, Pages RouterIn pages/_app.tsx, with next/script.

In Next.js, use next/script instead of a plain <script> element: React doesn't reliably run a plain script tag rendered through JSX.

import Script from "next/script";

<Script
  src="https://app.commmenty.com/embed.js"
  data-pf-origin="https://app.commmenty.com"
  data-pf-key="ak_…"
  strategy="afterInteractive"
/>

One URL per screen

Commmenty tells a prototype's screens apart by their URL: the path and the hash, never the query string. Each comment belongs to the URL it was left on. Its pin shows only there, and opening the comment takes you back to it.

Give every screen its own URL, a route such as /quotes or a hash such as #/quotes. If the prototype changes screens only through component state, or through a query parameter such as ?step=2, every comment lands on the same URL and a comment left on one screen can show up on another. The instructions from Copy prompt check this and ask you before changing anything.

A comment on a dialog, drawer or tab that opens without its own URL belongs to the screen behind it. While that dialog, drawer or tab is closed, the comment shows may have moved.

Allow Commmenty to frame it

Only if your prototype already sends a Content-Security-Policy header: add frame-ancestors https://app.commmenty.com to it. If it doesn't send one, add nothing. On Vercel, for example:

{
  "headers": [
    {
      "source": "/(.*)",
      "headers": [
        { "key": "Content-Security-Policy", "value": "frame-ancestors https://app.commmenty.com" }
      ]
    }
  ]
}

Never set X-Frame-Options. It blanks the prototype in some browsers.

Deploy it

Comments work once the deployed prototype has the script. Push the change to the branch that deploys the address you will share.

The prototype must be served over https. Plain http works only on localhost and 127.0.0.1.

Check it

When you create the prototype, Commmenty loads the address and waits for the script to answer. It says The script answered on this URL. when it works. If it doesn't answer, check that the change is deployed and try again, or choose Create anyway and fix it later. Troubleshooting lists every message.

The key

The data-pf-key in the script ties the prototype to your account, so it opens in Commmenty only for you and the people you share it with. The key is in every deployed copy of the script, so it isn't a secret.

Each prototype has its own key. Prototypes on the same site share one.

To replace it, open the prototype's page and choose Rotate key under Setup. The prototype stops opening until you deploy it with the new snippet.

Access key

Some prototypes protect themselves and load only with ?k= in the address. Commmenty can pass that key for you: turn on Access key under Advanced in the prototype's share settings, and copy the key into the prototype. One access key covers every prototype on the same site.

If you paste an address that already has ?k= into New prototype, Commmenty takes the key from it.