---
title: "Smart Citations extension"
description: "Configure Smart Citations and customize text review, references, and callbacks."
canonical_url: "https://tiptap.dev/docs/citations/api-reference/extension"
---

# Smart Citations extension

Configure Smart Citations and customize text review, references, and callbacks.

Import `SmartCitations` and its public types from `@tiptap-pro/extension-smart-citations`. The package also exports `createSources`, `defaultShouldReviewCitation`, and the [query functions](https://tiptap.dev/docs/citations/api-reference/queries.md). Run [citation commands](https://tiptap.dev/docs/citations/api-reference/commands.md) on `editor.commands`.

The runtime extension name is `smartCitations`. Inline citations use the `citation` mark. Node citations use the `smartCitations` node attribute, an array of `CitationAttributes` serialized to HTML as `data-node-citations`.

## Configuration

The configuration type for `SmartCitations` is `SmartCitationsOptions`.

| Option                  | Type                                                       | Required or default                                                                                                                                  |
| ----------------------- | ---------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| `sources`               | `SourceCollection \| null`                                 | Provide an application-owned [source collection](https://tiptap.dev/docs/citations/api-reference/sources.md). The default `null` fails editor setup. |
| `user`                  | `CitationUser \| (() => CitationUser)`                     | Required. Provide a nonempty string `id` and optional string `name`.                                                                                 |
| `shouldReviewCitation`  | `ShouldReviewCitation`                                     | Optional. Defaults to [`defaultShouldReviewCitation`](#text-review-rule).                                                                            |
| `renderCitation`        | `(context: CitationRenderContext) => CitationRenderResult` | Defaults to the source label or `Missing source`. See [reference rendering](https://tiptap.dev/docs/citations/guides/rendering.md).                  |
| `formatCopiedReference` | `(context: CopiedReferenceContext) => string \| null`      | Formats copied references as ` [Label]` by default. See [copy and paste](https://tiptap.dev/docs/citations/guides/copy-and-paste.md).                |
| `onCitationClick`       | `(context: CitationClickContext) => void`                  | Optional. See [references and clicks](https://tiptap.dev/docs/citations/guides/rendering.md).                                                        |
| `onError`               | `(error: CitationError) => void`                           | Optional. Receives expected command failures.                                                                                                        |

When the active user can change, pass a synchronous `user` callback that reads the current app state. Keep it free of side effects. Smart Citations calls it during setup, local edits, and validation for creation, approval, and restoration.

If the callback returns an invalid user during an edit, Smart Citations keeps the edit and prior attribution and reports `invalidUser`.

### Text review rule

`ShouldReviewCitation` is `(context: CitationReviewContext) => boolean`. Smart Citations calls it when the current and confirmed comparison strings for an inline citation differ. The context has four readonly fields.

| Field           | Type                                                     | Meaning                                                                                                        |
| --------------- | -------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| `text`          | `string`                                                 | Current comparison text. Hard breaks between cited ranges can appear as `\n`.                                  |
| `confirmedText` | `string`                                                 | Confirmed comparison text. Uses `citation.confirmedReviewText` if present, otherwise `citation.confirmedText`. |
| `citation`      | `Readonly<Omit<Citation, 'status' \| 'invalidReasons'>>` | Current citation before status and invalid reasons are calculated.                                             |
| `source`        | `SourceSnapshot \| undefined`                            | Current source, if present.                                                                                    |

Returning `true` adds `textChanged`. Returning `false` skips that reason and keeps the confirmed text for future comparisons. A changed or missing source can still invalidate either kind of citation.

`defaultShouldReviewCitation` takes `{ text, confirmedText }`. It trims both strings and collapses runs of whitespace to a single space. With `10 samples` as the confirmed text, `10  samples` returns `false`. `10samples`, `10 sam ples`, `12 samples`, and `10 Samples` return `true`.

Keep the callback synchronous and free of side effects. Use the same rule and equivalent source snapshots across collaborating editors to derive the same citation status.

### Copied reference format

`CopiedReferenceContext` contains the readonly fields `citation: Citation` and `label: string`. The label is the plain text of the displayed reference. Return the full string to append, including any spacing, or `null` to omit the label. The format applies to both plain-text and HTML clipboard content.
