Install Smart Citations

Set up Smart Citations in Tiptap and create your first citation.

Smart Citations is available through the pilot program. With pilot access, set up the Tiptap private registry, then install the packages for this browser example.

npm install @tiptap-pro/extension-smart-citations @tiptap/core@^3.30.1 @tiptap/pm@^3.30.1 @tiptap/starter-kit@^3.31.0

If you already have an editor, add Smart Citations to its extension list and keep its existing schema. StarterKit is only for the example. Collaboration is optional.

Add <div id="editor"></div> to the page before running this code in the browser.

import { Editor } from '@tiptap/core'
import StarterKit from '@tiptap/starter-kit'
import { SmartCitations, createSources, getCitations } from '@tiptap-pro/extension-smart-citations'

const sources = createSources([
  { id: 'manual', label: 'Editor manual', data: { text: 'An editor stores a document.' } },
])

const editor = new Editor({
  element: document.querySelector('#editor'),
  extensions: [StarterKit, SmartCitations.configure({ sources, user: { id: 'ada', name: 'Ada' } })],
  content: '<p>An editor stores a document.</p>',
})

editor.commands.setTextSelection({ from: 1, to: 10 })
editor.commands.createCitation({ sourceId: 'manual' })

console.log(getCitations({ editor })[0]?.status) // 'valid'

The example cites An editor and shows Editor manual after it. Use editor.can().createCitation({ sourceId }) to check a user's selection.

Prompt for coding agents

Copy this prompt into a coding agent working in your project.

Add Smart Citations to my existing Tiptap editor. Read these Markdown pages first.
https://tiptap.dev/docs/citations/getting-started/install.md
https://tiptap.dev/docs/citations/api-reference/extension.md
https://tiptap.dev/docs/citations/api-reference/commands.md
https://tiptap.dev/docs/citations/api-reference/queries.md
https://tiptap.dev/docs/citations/guides/sources.md
https://tiptap.dev/docs/citations/guides/review.md

Install @tiptap-pro/extension-smart-citations from the private registry with the project's
package manager. Check that @tiptap/core and @tiptap/pm satisfy ^3.30.1. If registry
authentication is missing, tell me how to set TIPTAP_PRO_TOKEN in the environment.
Keep the token out of code, logs, commits, and client bundles.

Keep the existing schema, extensions, and collaboration setup. Build one createSources()
collection using stable IDs, labels, and finite JSON data. Apply updates to that collection.
Configure SmartCitations with the collection and the app user. Use a synchronous user callback
if the active user can change.

Let users pick a source and cite the selection with createCitation({ sourceId }).
Use editor.can() to check the selection and onError to report command failures.

Verify that a new citation shows its reference label. With the default text review rule,
verify that doubling a space between words keeps the citation valid and deleting the
only space between those words adds textChanged. Restore or approve the text before
changing the source revision, then check for sourceChanged. Read the reasons with
getCitations({ editor }). Report any blockers.

For source updates and review workflows, see the Smart Citations guides.