Skip to content

Notion-like

The Notion-like editor supports collaborative block editing, writing assistance, emoji, and drag-and-drop reordering. The CLI copies its components into your project.

Start plan required

The Notion-like template requires at least a Start plan subscription to use in production. You can integrate and test it during your trial period. Usage of this template is subject to our Terms of Service and Pro License.

Installation

Sign in with a Tiptap account that has access to the template. The CLI uses your account to download the template and its private packages.

npx @tiptap/cli@latest login

For existing projects

npx @tiptap/cli@latest add notion-like-editor

For new projects

npx @tiptap/cli@latest init notion-like-editor

Styling

Load the shared variables and animations in your global stylesheet. Style setup

Configuration

The editor needs credentials for both Collaboration and writing assistance. The installed lib/tiptap-collab-utils.ts reads the following Next.js variables. In Vite, adapt that helper to read import.meta.env.VITE_* for each public value.

Environment variables

VariableValue
NEXT_PUBLIC_TIPTAP_COLLAB_APP_IDYour Tiptap Collaboration app ID.
NEXT_PUBLIC_TIPTAP_AI_APP_IDYour writing assistance app ID.
NEXT_PUBLIC_TIPTAP_COLLAB_TOKENA short-lived example Collaboration JWT for local development.
NEXT_PUBLIC_TIPTAP_AI_TOKENA short-lived example writing assistance JWT for local development.
NEXT_PUBLIC_TIPTAP_COLLAB_DOC_PREFIXAn optional prefix for document names.

JWT authentication

For production, set NEXT_PUBLIC_USE_JWT_TOKEN_API_ENDPOINT=true and implement POST /api/collaboration and POST /api/ai in your app. Each endpoint checks the user's session and access, signs a short-lived JWT with the corresponding server-side secret, and returns JSON with a token field. For local development with example tokens, leave the switch unset. JWT authentication

room prop

Use a stable room ID per document. Give collaborators editing the same document the same room ID.

Image uploads

The demo upload handler in lib/tiptap-utils.ts returns a placeholder. To keep the user's image, implement an upload endpoint that stores the file and responds with its URL. The example below sends multipart form data under file to /api/images and expects JSON with a url field.

For Amazon S3, install @aws-sdk/client-s3 and give your Node.js server permission to write to the bucket. In the endpoint, check the user's access, file type, and size before calling this helper. Pass the base URL where the browser can read the stored images.

import { randomUUID } from 'node:crypto'
import { PutObjectCommand, S3Client } from '@aws-sdk/client-s3'

const storage = new S3Client({})

export async function storeImage(file: File, bucket: string, publicBase: URL) {
  const key = `editor-images/${randomUUID()}`
  await storage.send(
    new PutObjectCommand({
      Bucket: bucket,
      Key: key,
      Body: new Uint8Array(await file.arrayBuffer()),
      ContentType: file.type,
    }),
  )

  // Keep the last path segment of the base, for example /uploads.
  const base = new URL(publicBase)
  if (!base.pathname.endsWith('/')) base.pathname += '/'

  return Response.json({ url: new URL(key, base).href })
}

Keep the existing file checks in handleImageUpload. The rest of the handler can send the file and return its URL.

const body = new FormData()
body.append('file', file)

const response = await fetch('/api/images', {
  method: 'POST',
  body,
  signal: abortSignal,
})

if (!response.ok) {
  throw new Error('Image upload failed')
}

const { url } = await response.json()
if (typeof url !== 'string' || !url) {
  throw new Error('The upload endpoint did not return an image URL')
}

onProgress?.({ progress: 100 })
return url

Usage

The generated Next.js page is available at /notion-like. To use the editor on your own route, pass the document ID as its room.

import { NotionEditor } from '@/components/tiptap-templates/notion-like/notion-like-editor'

export default function App() {
  return <NotionEditor room="my-document-room" placeholder="Start writing..." />
}

Features

  • Move blocks with the drag handle, or use the slash menu to insert headings, lists, tables, dividers, and math.
  • Format the selection with the floating toolbar, including marks, text color, highlights, links, and alignment.
  • Open the mention and emoji menus, insert images, and use the writing menu to revise a selection.
  • Edit with other participants and see their carets. The toolbar supports undo and redo.
  • Switch between light and dark themes. The toolbar adjusts to the available screen width.

Component breakdown

Hooks

  • use-cursor-visibility
  • use-floating-toolbar-visibility
  • use-is-breakpoint
  • use-tiptap-editor
  • use-ui-editor-state
  • use-window-size

Icons

  • arrow-left-icon
  • chevron-right-icon
  • external-link-icon
  • highlighter-icon
  • link-icon
  • moon-star-icon, sun-icon
  • more-vertical-icon
  • paint-bucket-icon
  • repeat-2-icon

Tiptap extensions

The template configures the collaboration and collaboration-caret extensions with a shared Yjs document, and the Ai extension from @tiptap-pro/extension-ai for writing assistance. It also uses StarterKit and the emoji, mention, mathematics, unique ID, placeholder, selection, typography, text style, color, highlight, text align, subscript, superscript, and task list extensions.

The CLI installs these extensions with the template:

  • ui-state-extension
  • indent-extension
  • list-normalization-extension
  • node-alignment-extension, node-background-extension
  • triple-click-block-selection-extension

Libs

  • tiptap-utils
  • tiptap-collab-utils

UI components

  • ai-ask-button, ai-menu, improve-dropdown
  • blockquote-button
  • code-block-button
  • color-highlight-button, color-highlight-popover
  • color-text-button, color-text-popover
  • copy-anchor-link-button, copy-to-clipboard-button
  • delete-node-button, duplicate-button, move-node-button
  • drag-context-menu
  • emoji-dropdown-menu
  • heading-button, heading-dropdown-menu
  • image-upload-button
  • indent-button
  • link-popover
  • list-button, list-dropdown-menu
  • mark-button
  • mention-dropdown-menu
  • reset-all-formatting-button
  • slash-command-trigger-button, slash-dropdown-menu
  • text-align-button
  • turn-into-dropdown
  • undo-redo-button

Nodes

  • blockquote-node
  • code-block-node
  • heading-node
  • horizontal-rule-node
  • image-node, image-node-pro, image-upload-node
  • list-node
  • paragraph-node
  • table-node
  • toc-node

Primitives

  • avatar
  • button, button-group
  • dropdown-menu
  • popover
  • separator, spacer, toolbar

Utilities

  • floating-element

Contexts

  • ai-context
  • user-context
  • collab-context

Collaboration

The collaboration provider connects each participant to the shared Yjs document for their room. Yjs merges concurrent changes. The caret extension shows participants' positions.

<NotionEditor room="team-notes" placeholder="Share your ideas..." />

AI integration

The writing menu can generate content from a prompt and revise a selection. Configure the app ID and token before opening the editor. Basic AI Generation extension