@bootstrapware/comments
v0.1.4
Published
Embeddable discussions on a host-owned resource. Local, BYO, or Bootstrapware Hosted.
Maintainers
Readme
@bootstrapware/comments
Embeddable discussions on a host-owned resource: threads with flat replies, plus nested replies for a page comment section or forum topics. Mentions, edit and delete, resolve and reopen, unread, and cursor load-more.
Local mode is free. BYO is $9.99 / month (you store discussions). Hosted is $19.99 / month (Bootstrapware stores them). Test keys are free. Bootstrapware does not authenticate end users. Wire the real session user.id.
pnpm add @bootstrapware/commentsPeer dependencies: react and react-dom (>= 18).
Local
import { Comments, createLocalAdapter } from "@bootstrapware/comments";
import "@bootstrapware/comments/styles.css";
<Comments
user={{ id: session.user.id, name: session.user.name }}
scope={{ tenantKey: workspace.id, resourceType: "task", resourceId: task.id }}
adapter={createLocalAdapter({ storageKey: "demo-comments" })}
/>Hosted
Publishable keys may appear in the browser. Secret keys stay on your server. The widget never mints author tokens.
<Comments
appId="cma_..."
publishableKey={process.env.NEXT_PUBLIC_BSW_COMMENTS_PUBLISHABLE_KEY}
user={{ id: session.user.id, name: session.user.name }}
scope={{ tenantKey: workspace.id, resourceType: "task", resourceId: task.id }}
authorToken={authorTokenFromYourServer}
renewAuthorToken={renewFromYourServer}
searchMentionCandidates={searchPeople}
resolveUsers={resolvePeople}
/>Optional apiBaseUrl defaults to https://comments.bootstrapware.co.
BYO ($9.99): pass a CommentsAdapter, or wrap one with createByoAdapter. Discussion text stays on your backend.
Layout
layout is "threads" (default), "section", or "forum".
- threads: several discussions on one record. The thread root and flat replies store
parentCommentId: null. They are siblings, not a tree. This is the backward-compatible default. - section: one chronological comment stream under a page, post, or record. Nested replies set
parentCommentId. There is no thread list. - forum: a topic list on the record. Each topic is a nested reply tree. Resolve and reopen still close that topic when resolve is enabled.
Depth 0 is top-level. Nested replies stop at depth 5. Chat is person-to-person messaging and is a different package. Feedback is feature requests and voting.
Presentation
presentation is separate from layout. It is "section" (default, inline on the page), "modal", "window", or "launcher". Modal, window, and launcher start closed unless defaultOpen. Escape closes them. The backdrop closes modal and launcher.
Bodies
Stored comment text stays plain. The widget renders **bold**, _italic_ or *italic* next to a letter or digit, `code`, [label](https://…) , and bare http/https URLs. Links use rel="nofollow noopener". Raw HTML and other schemes stay text.
onUnreadChange(count) runs when the unread total for the current view changes. Threads and forum use the loaded list for the active filter. Section uses the section's threads. Hosted and BYO.
New comments
Opening a thread, a forum topic, or a comment section shows one New comments divider where unread started. It stays on that loaded page, and is gone the next time that view is opened after those comments were marked read.
Theme
Optional theme="light" or theme="dark". Omit theme and the widget stays the light cream default. v1 does not follow prefers-color-scheme.
Set these on the embed root (.bsw-cm, or .bsw-cm[data-theme="dark"] when theme="dark"): --bsw-cm-bg, --bsw-cm-panel, --bsw-cm-fg, --bsw-cm-muted, --bsw-cm-line, --bsw-cm-accent, --bsw-cm-accent-fg, --bsw-cm-radius. primaryColor still sets --bsw-cm-accent.
License
MIT
