Open-source React editor
Posts with photos, video and links in one editor
Post Canvas is a rich-text editor with galleries, collages, video and social embeds built in, and output you can sanitize and render on your server. Built on Tiptap.
npm install post-canvas- Licence
- MIT
- React
- 18.2 and 19
- Languages
- 6
- Tests
- 425
Rich text
Writing tools people already know
Galleries
Four layouts for the same photos
Embeds
Paste a link, get a block
Presets
One editor, shaped for the job
A post that knows when it is an article
Bold, italic, links, mentions, hashtags, photos, galleries, video and embeds. No headings or tables.
- The status bar names the kind: text, photo, video or embed post.
- A second paragraph or a second photo makes it an article, and the title and cover appear.
<PostCanvas preset="social" />
Long form, with a title and a cover
Every block, plus a title field and a cover photo above the body. Publishing needs a title.
- Headings, tables, code, quotes and task lists.
- The status bar counts words and reading time.
<PostCanvas preset="article" />
A small box that posts on Enter
Paragraphs, bold, italic, links and mentions, and a 2,000 character limit. Shift and Enter adds a line.
- No toolbar: select text for the menu.
- Each comment renders with the read-only view.
<PostCanvas preset="comment" />
Safe output
Output you can trust on your server
The sanitizer, on a hostile document
Edit the JSON on the left. The right side updates as you type, with every removal listed.
After sanitizeDocument()
Removed (4)
linkunsafe value atdoc.content[0].content[0].marks[0]imageunsafe value atdoc.content[1]iframenot in the schema atdoc.content[2]videounsafe value atdoc.content[3]
Renders as
Claim your prize <img src=x onerror=alert(1)>
Thanks for reading.
HTML
<div class="pc-view" data-pc-theme="auto"><div class="pc-content"><p>Claim your prize <img src=x onerror=alert(1)></p><p>Thanks for reading.</p></div></div>Compare
How it compares
| Feature | Post Canvas | TinyMCE | Froala | Tiptap | Lexical |
|---|---|---|---|---|---|
| Licence | MIT | GPL-2.0 or later, or commercial | Commercial | MIT core, paid Pro extensions | MIT |
| Ready-made editor UI | Yes | Yes | Yes | No, you build it | No, you build it |
| Photo galleries and collage | Built in | Not built in | Not built in | You build it | You build it |
| Video and social embeds | Built in, click to load | Media plugin | Video insert | YouTube extension | You build it |
| Sanitizer for saved content on your server | Yes, the same schema as the editor | Bring your own | Bring your own | Bring your own | Bring your own |
| Real-time collaboration | Not yet | Paid plans | Collaboration plugin in the licence | Yjs and Hocuspocus | Yjs binding |
| Comments and track changes | Not yet | Paid plugins | In the collaboration plugin | Tiptap Cloud product | You build it |
| Frameworks | React and plain HTML | React, Vue, Angular and more | React, Vue, Angular and more | Any, with React and Vue packages | Any, with React bindings |
Quick start
Up and running in a few lines
- 1InstallOne package. React 18.2 or 19 is the only peer dependency.
- 2RenderPick a preset, pass your adapters, keep the JSON from onChange.
- 3Save and showSanitize on your server, then render with PostCanvasView or renderToHTML.
npm install post-canvas
import { PostCanvas } from 'post-canvas';
import 'post-canvas/styles.css';
export function Composer() {
return (
<PostCanvas
preset="social"
onChange={({ json }) => console.log(json)}
/>
);
}// app/write/post-editor.tsx: the editor is a Client Component
'use client';
import { PostCanvas } from 'post-canvas';
export function PostEditor({ onSave }: { onSave: (json: object) => void }) {
return <PostCanvas preset="article" onChange={({ json }) => onSave(json)} />;
}
// app/posts/[id]/page.tsx: the saved post renders on the server
import { PostCanvasView } from 'post-canvas/render';
export default async function PostPage({ params }: PageProps<'/posts/[id]'>) {
const post = await getPost((await params).id); // your own storage
return <PostCanvasView content={post.content} />;
}<link rel="stylesheet" href="https://unpkg.com/post-canvas@0.1.0/dist/cdn/post-canvas.css" />
<script src="https://unpkg.com/post-canvas@0.1.0/dist/cdn/post-canvas.iife.js"></script>
<div id="editor"></div>
<script>
const canvas = PostCanvas.create(document.getElementById('editor'), {
preset: 'article',
defaultContent: '<h2>Hello</h2><p>Start writing here.</p>',
});
canvas.on('change', (json) => console.log(json));
</script>Is Post Canvas free to use?
Yes. It is released under the MIT licence, so you can use it in commercial and closed-source products. The optional HEIC photo conversion uses heic-to, which is LGPL and which you install yourself if you want it.
Does it work with Next.js and React Server Components?
Yes. The editor is a Client Component. renderToHTML, PostCanvasView and sanitizeDocument run in Server Components and on any server, with no DOM, so saved posts render without shipping the editor to readers.
Can I use it without React?
Yes. The CDN build is one script and one stylesheet with React inside: call PostCanvas.create(element, options) on any page. With a bundler but no React, import post-canvas/vanilla.
Where do uploaded photos go?
Wherever your upload adapter sends them: S3, Cloudinary or your own route. The editor handles the picker, drag and drop, paste, progress, retry and cancel. Nothing is uploaded without your adapter.
Is it safe to show what people write?
Run sanitizeDocument on your server for any document a client sends. It keeps only what the schema allows, checks every URL and drops editor-only state. Players are built from validated ids at render time, never from stored HTML or iframe sources.
Does it support real-time collaboration?
Not yet. Collaboration, comments and track changes are on the roadmap. Today a document is plain Tiptap JSON that you save and load yourself.
How big is it?
About 282 kB gzipped for the editor with React external, and about 142 kB for renderToHTML on its own. The CDN file is about 389 kB with React inside. Code highlighting languages load only when a code block needs them.
Which languages does the interface speak?
English, German, Spanish, French, Italian and Portuguese. English ships in the main entry, the others are separate imports, and you can pass your own Locale object for any other language.
Try it with your own content
Switch presets, languages and features in the playground, then read the docs when you are ready to wire it up.