Configuration.

Pass your project key and any options when you initialize pinthread.

YOUR_PROJECT_KEY is a placeholder for a string. For hosted pinthread, copy the key returned by pinthread init. For self-hosting, use the project identifier configured on your server. Reuse the same key wherever you want to share feedback.

import { initPinthread } from 'pinthread';

initPinthread({
  project: 'YOUR_PROJECT_KEY',
  pageRoot: document.querySelector('#app'),
  scope: 'branch',
  branch: 'preview/navigation',
});

Client options

OptionTypeDefault / behavior
endpointstringHosted pinthread API by default. Override for self-hosting.
projectstringRequired. Use the string returned by setup. Public, not a credential.
repostringDefaults to the project key. Pass owner/repo to enrich agent prompts.
scope"project" | "branch"project: feedback shared across deployments. Use branch to isolate it.
branchstringDetected at build time by pinthread sync when branch scope is enabled.
enabledbooleantrue. Set false to omit the widget.
pageRootHTMLElementMounted content root for Frame. Defaults to a sole existing content element; multiple roots use Floating until pageRoot is set.
page() => stringCurrent pathname. Query strings and fragments excluded.
drawerContainerHTMLElementOptional element to center the drawer within.
autoHideDrawerbooleantrue. Set false to keep the drawer visible.
sidebar"background" | "edge""edge" (default) is a floating sidebar. "background" frames the page. Account → Sidebar switches Floating and Frame.
pollIntervalnumber4000 ms while the page is visible.
source(element: Element) => string | undefinedElement → repository-relative source file path.
sourceUrl(source: string, branch: string) => stringSource path and branch → editor or repository URL.
sessionDomainstringOptional parent domain you own. Never a public suffix.

Branch scope

npx pinthread init --branch-scope

Use this when feedback belongs to a particular change. Without it, matching page paths share comments across deployments.

For automatic branch detection, import initPinthread from the optional generated pinthread.config.js helper and run pinthread sync before your build. It checks deployment environment variables and Git. Set PINTHREAD_BRANCH when neither can identify the branch.

Source links

initPinthread({
  project: 'YOUR_PROJECT_KEY',
  source: element => element.closest('[data-source]')
    ?.getAttribute('data-source') ?? undefined,
});

Add data-source="src/components/Hero.tsx" to an element to include that file in copied feedback. Source references are provided by your site; pinthread does not upload your code.

Lifecycle

const review = initPinthread({ project: 'YOUR_PROJECT_KEY' });
review.open();    // Open the sidebar
review.close();   // Close it
await review.refresh();
review.destroy();

Destroy the instance when your application unmounts. Repeated initialization in the same document reuses the existing instance.