> For AI agents: the complete Sanity documentation index is available at [https://www.sanity.io/docs/llms.txt](https://www.sanity.io/docs/llms.txt).

# SDK-wired comment components

What each export of @sanity/collaboration/sdk replaces, and when to use it or drop down to the SDK hooks.

`@sanity/collaboration/sdk` joins the components to the App SDK. It has four exports, and each one replaces a piece of wiring you would otherwise write against the SDK hooks ([Comments in the App SDK](https://www.sanity.io/docs/collaboration/sdk-overview)). This page says which piece each one replaces, so you can tell when to reach for it and when to drop below it.

It assumes an app with the SDK set up ([Setup](https://www.sanity.io/docs/collaboration/sdk-overview)) and `@sanity/collaboration` installed ([Get started](https://www.sanity.io/docs/collaboration/get-started)). The setup is in those pages, and this one links to them rather than repeating them.

## SDKCommentsProvider: identity

The components need to know who is viewing and how to turn a user ID into a name and an avatar. `CommentsProvider` takes both as props; `SDKCommentsProvider` fills them in from the SDK's auth and user stores.

```typescript
import {SDKCommentsProvider} from '@sanity/collaboration/sdk'
```

```tsx
<Suspense fallback={<p>Resolving your identity…</p>}>
  <SDKCommentsProvider>{/* the comment surface */}</SDKCommentsProvider>
</Suspense>
```

It suspends until the current user is known. A logged-out viewer throws to the nearest error boundary, since the components have no anonymous mode.

Its own props say which resource users are resolved against: `projectId`, `organizationId`, and `resourceType`. `projectId` falls back to the surrounding `SanityApp`, and `resourceType` defaults to `'organization'` when you pass an `organizationId` and to `'project'` otherwise. Everything else passes through to `CommentsProvider`: `mentionOptions`, `reactionOptions`, `capabilities`, `formatTime`, `labels`, and the selection and linking props `activeComment`, `defaultActiveComment`, `onActiveCommentChange`, and `onActiveCommentNotFound`. See [Users and identity](https://www.sanity.io/docs/collaboration/users-and-identity) for what it fills in, and [Enable mentions](https://www.sanity.io/docs/collaboration/enable-mentions) and [Link to a comment](https://www.sanity.io/docs/collaboration/link-to-a-comment) for the props it passes on.

## SDKCommentsPanel: a document's panel

`CommentsPanel` takes threads and callbacks. `SDKCommentsPanel` takes a document handle instead, reads the threads with `useCommentThreads`, wires every card's writes with `useSDKThreadCallbacks`, and starts new threads with `createComment`.

```tsx
<SDKCommentsProvider>
  <ArticleEditor {...handle} />
  <Suspense fallback={<p>Loading comments…</p>}>
    <SDKCommentsPanel {...handle} compose={{fieldPath: 'title'}} />
  </Suspense>
</SDKCommentsProvider>
```

It renders no provider of its own, so it needs an `SDKCommentsProvider` above it. That is what lets it share identity and selection with an editor beside it: one `setActiveComment` drives both. It suspends until the threads have loaded, so the `Suspense` boundary above it is yours.

[Get started](https://www.sanity.io/docs/collaboration/get-started) renders one, step by step. Drop to `CommentsPanel` or `CommentList` when a write has to go through something of your own, or the data is not the SDK's.

## useSDKThreadCallbacks: a card's writes

Every write a `CommentThread` offers maps onto one `useCommentActions` call. `useSDKThreadCallbacks` writes that mapping for you and returns a function from a thread to its card's callbacks:

```tsx
const threadCallbacks = useSDKThreadCallbacks(handle)

<CommentThread thread={thread} {...threadCallbacks(thread)} />
```

Which callback calls which action is in [One callback, one action](https://www.sanity.io/docs/collaboration/data-flow). `onCopyLink` is not in it: only your app knows what its URLs look like.

Spread it before your own props, and anything you pass after wins. Failed writes go to `onError`, which defaults to `console.error`. See [Comment data flow](https://www.sanity.io/docs/collaboration/data-flow) and [Show a failed write](https://www.sanity.io/docs/collaboration/data-flow).

`onRetry` cannot re-send a thread parent anchored to a run of text, since creating it needs the anchor and a comment carries only the resolved selection. It reports that to `onError` instead; see [The adapter that writes the mapping for you](https://www.sanity.io/docs/collaboration/data-flow).

## SDKPortableTextComments: inline comments

`PortableTextComments` draws highlights and reports new comments and moved anchors through callbacks. `SDKPortableTextComments` sends those to `createComment` and `updateCommentAnchor`, and passes the editor's blocks as the anchor's `fieldValue` so a comment on unsaved text lands on the right words.

```tsx
<SDKPortableTextComments {...handle} path="body" threads={threads} />
```

It also needs an `SDKCommentsProvider` above it, since the composer it opens reads the current user and the mention options from there. The threads are still yours to read. [Comment on Portable Text](https://www.sanity.io/docs/collaboration/comment-on-portable-text) wires it step by step, and [Anchor inline comments](https://www.sanity.io/docs/collaboration/sdk-anchor-inline-comments) covers what it writes.

## Related

- The props, with the plain counterparts, in Storybook: [Providers](https://collaboration-platform.sanity.dev/?path=/docs/default-providers--docs), [CommentsPanel](https://collaboration-platform.sanity.dev/?path=/docs/default-commentspanel--docs), [Hooks](https://collaboration-platform.sanity.dev/?path=/docs/hooks--docs), and [Portable Text](https://collaboration-platform.sanity.dev/?path=/docs/portable-text--docs).
- [Levels of abstraction in the comment stack](https://www.sanity.io/docs/collaboration/levels-of-abstraction), for every rung between these and your own UI.



## Related changelog entries

Entries are listed newest first; each link points to the full entry as markdown. Follow one when you need to know what changed, when, or why — for example, to summarize recent updates, explain behavior that differs from older documentation, or check whether a fix has shipped.

- [@sanity/collaboration v0.2.0: Document-level comments, multi-document panels and DOM styling props](https://www.sanity.io/docs/changelog/320c84a9-99b0-4c42-b637-1c994bd83ffb.md) — October 29, 2026