Docs Demo Dashboard Get your key
On this page
  1. Quick start
    1. With an AI agent
  2. Where the tag goes
    1. Script tag
    2. ES module
    3. Frameworks and platforms

Install the script

One script tag turns any page into a place where people can leave comments pinned to specific elements. Visitors need no extension and no account.

Quick start

Paste this before the closing </body> tag of every page you want people to comment on. Pick how the toolbar appears, add your key, and copy:

<script async
  src="https://sharedlayers.com/comments.umd.js"
  data-key="sl_embed_…">
</script>

Your key is in the dashboard under API Key. Reload the page and the toolbar appears: along the top as a bar, or in the corner you picked. Anyone who visits can enter a name and start commenting. Every option is described under Configuration.

The SharedLayers bar across the top of a demo page, above the site's own header: the layer, Comment, filters, the side panel and Log in, at the right.
The bar, the default layout, on our demo page. The site's own header moves down to make room.

Installing by script is part of the Pro plan. On the free plan the script logs one line to the console and does not appear. The Chrome extension shows the same comments on any site and is free. See Script or extension?

With an AI agent

If Claude Code, Codex, Cursor or Copilot is putting the tag in for you, give it this line with the tag. It adds the tag where your framework wants it, then looks through your sheets, dialogs and drawers for what would keep pins from staying on their elements, checks them in the browser, and proposes the fixes before making them: a role, a name of their own, a test id. Copy it with instructions, under the snippet on the API Key page, copies the two together with your key.

Add SharedLayers to this app with the script tag below. Follow https://sharedlayers.com/skills/add-sharedlayers/SKILL.md,
which also checks that comment pins will stay on their elements, and propose
any changes beyond the tag before making them.

That is the whole installation. The rest of this page is about where the tag goes; the script reference is for when you want to change how it behaves, or need to know what it is doing.

Where the tag goes

Script tag

The file at https://sharedlayers.com/comments.umd.js is a classic script. When it runs it reads its own tag for data- attributes and initialises itself. A few things follow from that:

ES module

The same build is also served as an ES module at https://sharedlayers.com/comments.es.js. It exports one object, Comments, with one method, init. A module has no document.currentScript, so you pass the options yourself:

<script type="module">
  import { Comments } from 'https://sharedlayers.com/comments.es.js';
  Comments.init({ key: 'sl_embed_…' });
</script>

The same import works from a bundler if you would rather vendor the file. init returns a promise that resolves once the widget has mounted, or once it has decided not to. On a repeat visit within the hour it mounts on the remembered key check and resolves before the fresh answer is back; see Loading and performance. It never rejects: every refusal is a console warning, not an exception, so a broken key cannot take down your page.

There is no destroy. The widget lives for the lifetime of the page.

OptionTypeDefault
keystringrequired
layout'bar' | 'button' | 'floating''bar'
placement'top-right' | 'top-left' | 'bottom-right' | 'bottom-left''bottom-right'
pageParamsstring[]none
snapshotsbooleantrue
projectIdstringlegacy, see projectId

Frameworks and platforms

The script does not care how the page was built. It needs to end up as a script tag in the served HTML, once, on the pages you want reviewed.

Next.js (App Router)

// app/layout.tsx
import Script from 'next/script';

export default function RootLayout({ children }) {
  return (
    <html>
      <body>
        {children}
        <Script
          src="https://sharedlayers.com/comments.umd.js"
          data-key="sl_embed_…"
          strategy="afterInteractive"
        />
      </body>
    </html>
  );
}

React, Vue, Svelte, Angular and other single-page apps

Put the tag in the one HTML file the app is served from, usually index.html. Do not mount it inside a component: components unmount and remount, and the widget is meant to be installed once. Client-side navigation is handled for you. See Single-page apps.

Only on staging

Most teams want comments on staging and preview environments, not on production. The cleanest way is to render the tag only in those builds. When you cannot, gate it by hostname:

<script>
  if (!/(^|\.)acme\.com$/.test(location.hostname) || location.hostname.startsWith('staging.')) {
    const s = document.createElement('script');
    s.src = 'https://sharedlayers.com/comments.umd.js';
    s.dataset.key = 'sl_embed_…';
    document.body.appendChild(s);
  }
</script>

A dynamically created tag works because the browser still sets document.currentScript while it runs. Staging and production on one domain share a key, and each keeps its own comments: see Addresses.

On your own computer

On localhost and other local addresses the script keeps comments in the app's project folder rather than on SharedLayers, in Chrome and Edge. See Apps on your computer.

WordPress

Add the tag to your theme's footer.php before </body>, or use a header-and-footer plugin that lets you paste raw HTML into the footer.

Webflow, Squarespace, Wix, Shopify

Each has a place for custom code injected before </body>. In Webflow it is Site settings, Custom code, Footer code. In Shopify it is the theme's theme.liquid. Paste the tag there.

Google Tag Manager

A Custom HTML tag containing the snippet works. Prefer a direct tag in the page when you can: a tag manager adds its own delay, and reviewers on the page have to wait for it.