Novel — Notion-Style AI Editor Component
WYSIWYG editor with AI autocompletion, slash commands, and bubble menu. Drop into any React app. 16K+ GitHub stars.
What it is
Novel is an open-source WYSIWYG editor component for React that provides a Notion-like editing experience with AI-powered autocompletion. It includes slash commands for inserting blocks, a bubble menu for formatting selections, and an AI completion feature that generates text inline. Built on Tiptap and ProseMirror.
It targets developers building applications that need a rich text editor with a modern, Notion-style interface and optional AI writing assistance.
How it saves time or tokens
Novel provides a production-ready editor component that would take weeks to build from scratch. Instead of configuring Tiptap, building a slash command system, designing a bubble menu, and integrating AI completion, you install Novel and get all of these features. The AI completion connects to your own API endpoint, so you control the model and costs.
How to use
- Install the package:
npm install novel
- Drop into your React app:
import { Editor } from 'novel';
export default function Page() {
return (
<Editor
defaultValue={initialContent}
onUpdate={(editor) => {
console.log(editor.getJSON());
}}
/>
);
}
- Configure AI completion with your own endpoint:
<Editor
completionApi="/api/generate"
defaultValue={initialContent}
/>
Example
import { Editor } from 'novel';
import { useState } from 'react';
export default function DocumentEditor() {
const [content, setContent] = useState({});
const [saving, setSaving] = useState(false);
const handleSave = async () => {
setSaving(true);
await fetch('/api/documents', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ content })
});
setSaving(false);
};
return (
<div>
<button onClick={handleSave}>
{saving ? 'Saving...' : 'Save'}
</button>
<Editor
completionApi="/api/ai/complete"
defaultValue={{}}
onUpdate={(editor) => setContent(editor.getJSON())}
className="min-h-[500px] border rounded p-4"
/>
</div>
);
}
Related on TokRepo
- AI tools for content -- Content creation and editing tools
- Featured workflows -- Curated developer tools and components
Common pitfalls
- The AI completion feature requires a server-side API endpoint that streams text. The endpoint must return a ReadableStream for the inline typing effect to work.
- Novel is built for React. Vue, Svelte, and vanilla JS are not supported directly. For other frameworks, use Tiptap directly.
- Customizing the editor beyond the provided options requires understanding the underlying Tiptap and ProseMirror architecture.
Frequently Asked Questions
No. The AI autocompletion is optional. Novel works as a standard rich text editor without AI features. If you want AI completion, you provide your own API endpoint via the completionApi prop. This endpoint can connect to any LLM provider.
Yes. Novel uses Tailwind CSS for styling. You can pass custom className props and override the default styles. The slash command menu, bubble menu, and editor area are all customizable through Tailwind classes or CSS.
Novel outputs content as Tiptap/ProseMirror JSON or HTML. The onUpdate callback provides an editor instance with getJSON() and getHTML() methods. You can store the JSON format for lossless round-tripping or HTML for rendering elsewhere.
Novel provides a similar editing experience to Notion -- slash commands, block-based editing, and inline formatting. However, Novel is an embeddable component, not a full application. You integrate it into your own app and handle storage, permissions, and collaboration yourself.
Yes. Novel works with Next.js out of the box. The editor component renders on the client side. For the AI completion feature, create an API route in Next.js that proxies requests to your LLM provider and streams the response back to the editor.
Citations (3)
- Novel GitHub Repository— Novel is a Notion-style WYSIWYG editor with AI autocompletion
- Novel Documentation— Novel is built on Tiptap and ProseMirror
- Vercel AI SDK Documentation— AI-assisted writing improves content creation productivity
Related on TokRepo
Source & Thanks
Created by Steven Tey. Licensed under Apache-2.0.
novel — ⭐ 16,100+