how it’s built/step 07 of 10

Comments and follows

Readers reply as their own polis sites, from your pages.

On polis a reader comments as their own polis site: the comment is published, signed, on their site, and points at the post. The author blesses the ones they accept. So the comment box on your website isn't a form that posts to you: it acts on the reader's own site, with the reader's own consent.

@polis-pub/next/comments drops in polis's widget for one post:

import { PolisComments } from '@polis-pub/next/comments';

<PolisComments className="widget" author="vdibart.polis.pub" post={post.url} />

A reader connects once per website; their site asks them, and the token it issues works only on your website's origin, and only to comment, follow and unfollow. Style the widget with CSS custom properties and ::part():

.widget {
  --text: var(--ink);
  --site-mid: var(--muted);
  --font-content: var(--font-read);
}
.widget::part(go) { border-radius: 4px; }

There are three levels of control, so pick the one you need:

  1. Drop-in: the component above.
  2. Drop-in plus events: listen on document for polis:comment-posted, polis:followed and polis:signed-in.
  3. Headless: import { social } from '@polis-pub/sdk' (browser only) and build your own interface on the same functions the widget uses.

⚠️ Comments only work from a website the author has authorised (step 9). Until then the reader's site refuses to connect from it, and that's deliberate.