Install Post Canvas
Install Post Canvas, import its stylesheet, and learn which entry point to use for the editor, the server and plain HTML pages.
This page covers the package, its peer dependencies, the stylesheet and the entry points. For a full walkthrough, pick your setup: React and Vite, Next.js or plain HTML from a CDN.
Install the package
npm install post-canvasPost Canvas lists react and react-dom as peer dependencies, version 18.2 or newer (19 works too). Your app provides them. Tiptap, ProseMirror and the other libraries the editor needs come with the package, so you do not install them yourself.
The package is ESM only and ships TypeScript types. The server entries need Node 20.19 or newer.
Import the stylesheet
The editor and the read-only view share one stylesheet. Import it once, near the root of your app:
import 'post-canvas/styles.css';The editor and PostCanvasView are themed with CSS custom properties, and the theme prop picks light, dark or auto (follow the reader's system setting). If you show saved HTML from renderToHTML, load the same stylesheet on that page: the output is wrapped in .pc-view and .pc-content, and those classes carry the styling. See rendering.
Entry points
Each entry has one job. Import only from these paths.
| Entry | Use it for | Needs React | Needs a DOM |
|---|---|---|---|
post-canvas | The PostCanvas editor, usePostCanvasEditor, presets, resolveFeatures, hasPendingUploads, CoverField, embed provider helpers and all shared types | Yes | Yes, to run the editor |
post-canvas/extensions | The Tiptap extensions and schema pieces, for a custom editor setup or a custom node | No | No for the schema, yes for node views |
post-canvas/render | Showing documents: renderToHTML, PostCanvasView, toMarkdown, fromMarkdown, fromHTML, toPlainText, excerpt, sanitizeDocument, activateEmbeds, resolveFeatures and the embed provider registry | Only for PostCanvasView | No, except fromHTML and activateEmbeds |
post-canvas/server | What a backend needs: validateDocument, sanitizeDocument, renderToHTML, fromHTML, resolveFeatures, and the embed and link preview resolvers | No | No |
post-canvas/vanilla | The editor without writing React: createPostCanvas, plus renderToHTML, activateEmbeds, sanitizeDocument and registerEmbedProvider | Bundled inside | Yes |
post-canvas/locales/<code> | A language other than English: de, es, fr, it, pt (and en) | No | No |
post-canvas/styles.css | The stylesheet | No | No |
A few details that save time:
validateDocument,sanitizeDocumentandrenderToHTMLrun on a server, in a Server Component and in edge runtimes. The two resolvers (createEmbedResolverandcreateLinkPreviewResolver) loadundiciandnode:dnswhen they first run, so they need Node.fromHTMLparses HTML. In a browser it usesDOMParser. On a server you pass a window from a DOM library such as happy-dom (see security and the server reference).hasPendingUploadslives inpost-canvas, not inpost-canvas/server, because it checks editor state before you save.hasTransientContentis inpost-canvas,post-canvas/renderandpost-canvas/server.- The editor renders on the client only. Server-rendering your page is fine, but the editor itself mounts in the browser. The Next.js guide shows the setup.
A second language
English is the default. To use another language, import its locale and pass it as locale:
import { PostCanvas } from 'post-canvas';
import de from 'post-canvas/locales/de';
export default function App() {
return <PostCanvas locale={de} />;
}See the i18n guide for writing your own locale.
Browser support
Post Canvas targets current evergreen browsers: recent versions of Chrome, Edge, Firefox and Safari, on desktop and on phones. We do not publish a list of exact versions, and we do not target Internet Explorer or other old browsers. If you need a specific older version, test the playground on it first.
Next steps
- Follow a setup guide: React and Vite, Next.js or CDN.
- Read how a document is stored in document JSON.
- Choose a preset and connect adapters.
Introduction to Post Canvas
Post Canvas is a React editor for posts and articles, with rich text, photo galleries, embeds and a safe way to show what people write.
React and Vite
Set up the Post Canvas editor in a Vite and React app, save its JSON, and show a saved post with PostCanvasView or renderToHTML.