skills/superdoc-react/SKILL.md
React integration guidelines for SuperDoc document editor. Use when adding document editing capabilities to React or Next.js applications, working with DOCX files, or implementing collaboration features. Triggers on tasks involving document editors, DOCX handling, or SuperDoc integration.
npx skillsauth add superdoc-dev/agent-skills superdoc-reactInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Official React wrapper for SuperDoc - the document editing and rendering library for the web. Provides component-based API with proper lifecycle management and React Strict Mode compatibility.
Reference these guidelines when:
npm install @superdoc-dev/react
superdocis included as a dependency - no separate installation needed.
import { SuperDocEditor } from '@superdoc-dev/react';
import '@superdoc-dev/react/style.css';
function App() {
return (
<SuperDocEditor
document={file}
documentMode="editing"
onReady={() => console.log('Editor ready!')}
/>
);
}
| Prop | Type | Default | Description |
|------|------|---------|-------------|
| document | File \| Blob \| string \| object | required | Document to load |
| documentMode | 'editing' \| 'viewing' \| 'suggesting' | 'editing' | Editing mode |
| role | 'editor' \| 'viewer' \| 'suggester' | 'editor' | User permissions |
| Prop | Type | Description |
|------|------|-------------|
| user | { name, email?, image? } | Current user info |
| users | Array<{ name, email, image? }> | All users (for @-mentions) |
| Prop | Type | Default | Description |
|------|------|---------|-------------|
| id | string | auto-generated | Custom container ID |
| hideToolbar | boolean | false | Hide the toolbar |
| rulers | boolean | - | Show/hide rulers |
| className | string | - | CSS class for wrapper |
| style | CSSProperties | - | Inline styles |
| renderLoading | () => ReactNode | - | Custom loading UI |
| Prop | Type | Description |
|------|------|-------------|
| onReady | ({ superdoc }) => void | Editor initialized |
| onEditorCreate | ({ editor }) => void | ProseMirror editor created |
| onEditorDestroy | () => void | Editor destroyed |
| onEditorUpdate | ({ editor }) => void | Content changed |
| onContentError | (event) => void | Document parsing error |
| onException | ({ error }) => void | Runtime error |
| Prop | Type | Description |
|------|------|-------------|
| modules | object | Configure collaboration, AI, comments |
Access SuperDoc methods via ref:
import { useRef } from 'react';
import { SuperDocEditor, SuperDocRef } from '@superdoc-dev/react';
function Editor() {
const editorRef = useRef<SuperDocRef>(null);
const handleExport = async () => {
await editorRef.current?.getInstance()?.export({ triggerDownload: true });
};
return <SuperDocEditor ref={editorRef} document={file} />;
}
| Method | Returns | Description |
|--------|---------|-------------|
| getInstance() | SuperDoc \| null | Access underlying instance |
| setDocumentMode(mode) | void | Change mode without rebuild |
| export(options?) | Promise<Blob \| void> | Export as DOCX |
| getHTML(options?) | string[] | Get document as HTML |
| focus() | void | Focus the editor |
| search(text) | SearchResult[] | Search document |
| goToSearchResult(match) | void | Navigate to result |
| setLocked(locked) | void | Lock/unlock editing |
| toggleRuler() | void | Toggle ruler visibility |
The component handles documentMode prop changes efficiently without rebuilding:
function Editor() {
const [mode, setMode] = useState<DocumentMode>('editing');
return (
<>
<button onClick={() => setMode('viewing')}>View</button>
<button onClick={() => setMode('editing')}>Edit</button>
<SuperDocEditor document={file} documentMode={mode} />
</>
);
}
function FileEditor() {
const [file, setFile] = useState<File | null>(null);
return (
<>
<input
type="file"
accept=".docx"
onChange={(e) => setFile(e.target.files?.[0] || null)}
/>
{file && <SuperDocEditor document={file} />}
</>
);
}
<SuperDocEditor
document={file}
renderLoading={() => <div className="spinner">Loading...</div>}
onReady={() => console.log('Ready!')}
/>
<SuperDocEditor
document={file}
documentMode="viewing"
role="viewer"
hideToolbar
/>
<SuperDocEditor
document={file}
user={{
name: 'John Doe',
email: '[email protected]',
image: 'https://example.com/avatar.jpg'
}}
users={[
{ name: 'Jane Smith', email: '[email protected]' },
{ name: 'Bob Wilson', email: '[email protected]' },
]}
/>
The React wrapper handles SSR automatically (renders null or renderLoading() on server, initializes after hydration).
// app/editor/page.tsx
'use client';
import { SuperDocEditor } from '@superdoc-dev/react';
import '@superdoc-dev/react/style.css';
export default function EditorPage() {
return (
<SuperDocEditor
document="/sample.docx"
documentMode="editing"
style={{ height: '100vh' }}
/>
);
}
// pages/editor.tsx
import { SuperDocEditor } from '@superdoc-dev/react';
import '@superdoc-dev/react/style.css';
export default function EditorPage() {
return (
<SuperDocEditor
document="/sample.docx"
documentMode="editing"
style={{ height: '100vh' }}
/>
);
}
For custom loading UI during SSR:
'use client';
import dynamic from 'next/dynamic';
const SuperDocEditor = dynamic(
() => import('@superdoc-dev/react').then(mod => mod.SuperDocEditor),
{
ssr: false,
loading: () => <div>Loading editor...</div>
}
);
Import styles once in your layout:
// app/layout.tsx
import '@superdoc-dev/react/style.css';
export default function RootLayout({ children }) {
return (
<html>
<body>{children}</body>
</html>
);
}
import * as Y from 'yjs';
import { WebsocketProvider } from 'y-websocket';
function CollaborativeEditor() {
const ydoc = useMemo(() => new Y.Doc(), []);
const provider = useMemo(
() => new WebsocketProvider('wss://your-server.com', 'doc-id', ydoc),
[ydoc]
);
return (
<SuperDocEditor
document={file}
modules={{
collaboration: { ydoc, provider },
}}
/>
);
}
These props trigger a full instance rebuild when changed:
| Prop | Reason |
|------|--------|
| document | New document to load |
| user | User identity changed |
| users | Users list changed |
| modules | Module configuration changed |
| role | Permission level changed |
| hideToolbar | Toolbar DOM structure changed |
Other props like documentMode and callbacks are handled efficiently without rebuild.
import type {
SuperDocEditorProps,
SuperDocRef,
DocumentMode,
UserRole,
SuperDocUser,
SuperDocModules,
SuperDocConfig,
SuperDocInstance,
} from '@superdoc-dev/react';
Types are extracted from the superdoc package, ensuring they stay in sync.
| Requirement | Version | |-------------|---------| | React | 16.8.0+ | | Node.js | 16+ |
| Example | Description | |---------|-------------| | React + TypeScript | File upload, mode switching, export | | Next.js SSR | App Router with SSR support |
development
Core SuperDoc usage guidelines for document editing applications. Use when integrating SuperDoc with vanilla JavaScript, Vue, Svelte, or other frameworks. Triggers on tasks involving DOCX editing, document rendering, or SuperDoc configuration.
development
Maintainer-only workflow for handling GitHub Secret Scanning alerts on OpenClaw. Use when Codex needs to triage, redact, clean up, and resolve secret leakage found in issue comments, issue bodies, PR comments, or other GitHub content.
development
Maintainer workflow for OpenClaw releases, prereleases, changelog release notes, and publish validation. Use when Codex needs to prepare or verify stable or beta release steps, align version naming, assemble release notes, check release auth requirements, or validate publish-time commands and artifacts.
development
Run, watch, debug, and extend OpenClaw QA testing with qa-lab and qa-channel. Use when Codex needs to execute the repo-backed QA suite, inspect live QA artifacts, debug failing scenarios, add new QA scenarios, or explain the OpenClaw QA workflow. Prefer the live OpenAI lane with regular openai/gpt-5.4 in fast mode; do not use gpt-5.4-pro or gpt-5.4-mini unless the user explicitly overrides that policy.