Docs

Configuration

Configure with data- attributes on the script tag — all optional:

<script
  src="https://cdn.jsdelivr.net/npm/@perpetio/redline/redline.js"
  data-project="marketing-site"
  data-accent="#bd3426"
  data-theme="auto"
  data-position="bottom-right"
  data-start-open="true"
  data-note="Focus on the hero copy and pricing — flag anything off-brand."
  data-spa="true"
  data-post-url="https://feedback.example.com/feedback"
  data-share-email="https://github.com/org/repo/issues/new?title=Review%20{page}&amp;body={summary}"
  defer
></script>
Attribute Default Description
data-project "" Namespace for stored comments. Keep separate sites apart.
data-page location.pathname Page key comments are grouped under.
data-accent — Brand color for primary buttons & the active tool.
data-theme auto light, dark, or auto (sniffs your page background).
data-position bottom-right bottom-right or bottom-left.
data-blocks sensible default CSS selector for "section note" (+) targets.
data-start-open false Set to true to show the review toolbar immediately instead of the collapsed Review pill.
data-note — Author's note to reviewers — what should be reviewed. Shown when they start and atop the comments panel.
data-spa false Watch pushState, replaceState, and popstate for page changes, so each route keeps its own comments. Without it, a page that changes its address and never calls refresh() gets a console warning.
data-post-url — URL that receives an explicit HTTP POST of the current page's export JSON. Adds Send feedback.
data-share-email — Email address or URL template for Share. {page}, {count}, and {summary} become URL-encoded values for a prefilled GitHub, GitLab, Jira, or other issue URL.
data-capture styles,components Extras each new comment records besides the element description: styles, components, both, or off. Component and source info only exists in development builds.
data-editor-url — "Open in editor" link template, e.g. vscode://file/Users/me/app/{path}:{line}. {path}, {line}, {column} come from the comment's source file.

For programmatic setup, import the ES module and call init(config):

npm install @perpetio/redline
import Redline from '@perpetio/redline';

Redline.init({
  project: 'marketing-site',
  accent: '#bd3426',
  spa: true,
  postUrl: '/feedback',
});
// Call Redline.destroy() when unmounting or during hot reload.

The classic script still supports window.RedlineConfig set before it loads. For a script injected after page load, call window.Redline.init(config). init() can be called again after destroy() without leaving listeners behind. TypeScript declarations are included in the package.

Sharing comments

Sharing is an explicit action:

  1. A reviewer opens the Comments panel (toolbar list icon or press A).
  2. They click Download (⬇) to save a redline-<page>-<date>.json file.
  3. They send you that file.
  4. You open the same page, click Import (⬆), pick the file — every comment reappears anchored in place.

Reviewing a whole site? When other pages have comments too, the footer offers All pages under the buttons: one file with every page's comments. Import it on any page of the site and each comment goes back to the page it was made on (the project name may differ between the two browsers).

To paste feedback directly into another tool, click Copy to copy the same complete, import-compatible JSON payload to the clipboard.

You can also drive this from code (see the API below).

Send feedback to your server

Set data-post-url on the classic script or postUrl in init(config). Reviewers will see a Send feedback button. It POSTs the same JSON export to your endpoint with Content-Type: application/json. A successful response must have a 2xx status. Sending does not delete the browser's local comments.

Every POST body carries a top-level deliveryId. It stays the same across the retries of one submit, so store it and answer a repeat with success without saving twice (the example receiver does). Failed sends are retried up to data-post-retries times (default 3, at most 5) on network errors, timeouts, 408, 429 and 5xx; other statuses such as 400 are not retried. Waits are 1 s, 2 s, 4 s…, or the receiver's Retry-After (seconds or an HTTP date, capped at 30 s). A cross-origin browser reads Retry-After only if the receiver lists it in Access-Control-Expose-Headers.

<script src="/redline.js" data-post-url="https://feedback.example.com/feedback" defer></script>

Any endpoint that accepts a JSON POST works as the receiver. Answer 2xx once the feedback is stored. Retries reuse the body's deliveryId, so a repeat can return the first result. Before exposing a receiver publicly, add your site's authentication and rate limits.

Prefill an issue

data-share-email also accepts an issue creation URL. The values of {page}, {count}, and {summary} are URL encoded before substitution. For example:

<script src="/redline.js"
  data-share-email="https://github.com/org/repo/issues/new?title=Review%20{page}&amp;body={summary}"
  defer></script>

The issue link contains a short comment summary. Download or send the full JSON when teammates need to import annotations and their anchors.