blockcn

Quick start

Go from an empty project to a working block editor in about five minutes.

This page is the shortest path to a working editor. Each step links to a longer explanation if you need it.

Before you start

You need Node.js 20+ and a React app on Tailwind CSS v4 with a src/ directory. If you already have one, skip step 1.

Create an app

npx create-next-app@latest my-app --typescript --tailwind --app --src-dir --import-alias "@/*"
cd my-app

Initialize shadcn

npx shadcn@latest init

This adds your theme tokens, tw-animate-css and src/lib/utils.ts. The editor is styled with these tokens.

Add the editor

npx shadcn@latest add https://blockcn.com/r/editor-shell.json

This copies the editor into src/ and installs Tiptap and the other packages it needs.

Create the editor component

Create src/components/block-editor.tsx:

src/components/block-editor.tsx
"use client";

import { Editor } from "@/components/editor/Editor";
import { useEditor } from "@/components/editor/useEditor";
import { createEditorExtensions } from "@/editor-core/schema/extensions";

// Keep this outside the component. The editor is created once; pass deps
// to useEditor when this array should be rebuilt.
const extensions = createEditorExtensions();

export function BlockEditor() {
  // Your saved document (Tiptap JSON or HTML). Omit `content` to start empty.
  const editor = useEditor({ extensions, content: "<h1>Untitled</h1><p>Type / for blocks.</p>" });

  return (
    <Editor editor={editor}>
      <Editor.Frame>
        <Editor.Content />
        <Editor.Chrome />
      </Editor.Frame>
      <Editor.Outline />
    </Editor>
  );
}

To try every block first, pass DEFAULT_EDITOR_CONTENT (also from @/components/editor/useEditor), the demo document. Swap it out before you ship: it adds about 280 lines of sample text to your bundle.

Render it

The editor needs the browser, so load it with server rendering turned off:

src/app/page.tsx
"use client";

import dynamic from "next/dynamic";

const BlockEditor = dynamic(
  () => import("@/components/block-editor").then((m) => m.BlockEditor),
  { ssr: false },
);

export default function Page() {
  return (
    <main className="mx-auto max-w-3xl px-4 py-10">
      <BlockEditor />
    </main>
  );
}

Run it

npm run dev

You should see a demo document. Omit content to start from an empty page instead. Type / on an empty line to insert a block, select text to format it, and drag the handle on the left to move blocks.

Next steps

Something not working? See Troubleshooting.

On this page