Configuration is passed when creating a SuperDoc instance. Only two fields are required.
Quick start
new SuperDoc({
selector: "#editor", // Required: Where to render
document: "contract.docx", // Required: What to load
});
Core parameters
selector
string | HTMLElement
required
DOM selector or element where SuperDoc will mount.selector: '#editor'
// or
selector: document.querySelector('.my-editor')
document
Document | string | File
required
Document to load.Can be a Document (Object), string or File
{
id: 'doc-123', // string
type: 'docx', // string, can be 'docx' or 'pdf'
data: File // File or Blob
}
string - URL to fetch
File - From file input
Use documents array for multiple documents instead
Multiple documents to load (alternative to single document)documents: [
{ id: 'doc-1', type: 'docx', data: fileObject },
{ id: 'doc-2', type: 'pdf', url: 'report.pdf' }
]
File - From file input (e.g., from <input type="file">)
string (URL) - To fetch the document
Unique identifier for this SuperDoc instance
Auto-generated UUID if not provided
User & permissions
All users with document access. Used for @mentions and collaboration.
User permission level
editor - Full editing capabilities
viewer - Read-only access
suggester - Can only suggest changes
Role overrides documentMode when more restrictive
documentMode
string
default:"'editing'"
Initial document mode
editing - Normal editing
viewing - Read-only display
suggesting - Track changes enabled
Viewing-mode visibility controls for standard comments
Show comment highlights and threads when documentMode is viewing
Viewing-mode visibility controls for tracked changes
Show tracked-change markup and threads when documentMode is viewing
Override permission checks for comments and tracked changesconst superdoc = new SuperDoc({
user: { name: 'Alex Editor', email: 'alex@example.com' },
permissionResolver: ({ permission, trackedChange, defaultDecision }) => {
if (permission === 'RESOLVE_OTHER' && trackedChange) {
return false; // Block accepting suggestions from other authors
}
return defaultDecision;
},
});
Return false to block an action. Return true or undefined to fall back to the built-in permission matrix.
Modules
Configure optional modules
Collaboration module
Real-time collaboration settings
providerType
string
default:"'hocuspocus'"
Provider implementation
Additional connection parameters
Comments system configuration
DOM element for comments list
Comments-only override for the permission resolver
Toolbar configuration
groups
string[]
default:"['left', 'center', 'right']"
Layout groups
Available font families. See Toolbar fonts for details.Custom fonts from DOCX files will display in the toolbar but won’t be selectable unless loaded in your app and added here.
Container-based responsive sizing
Appearance
title
string
default:"'SuperDoc'"
Document title for exports and display
Colors for user awareness and highlighting
Built-in palette provided by default
Document view options for controlling layout
Document view layout mode
'print' - Fixed page width, displays document as it prints (default)
'web' - Content reflows to fit container width
Use 'web' for mobile devices and WCAG AA reflow compliance (Success Criterion 1.4.10). When set to 'web', the layout engine is automatically disabled.
viewOptions: { layout: 'web' }
Removed in v1.0 — Use viewOptions.layout instead. 'paginated' → 'print', 'responsive' → 'web'.
Removed in v1.0 — Use CSS to control margins in web layout mode.
DOM element for toolbar
Alternative to modules.toolbar.selector
Advanced options
Additional SuperDoc extensions
Custom image upload handlerhandleImageUpload: async (file) => {
const formData = new FormData();
formData.append('image', file);
const response = await fetch('/upload', {
method: 'POST',
body: formData
});
const { url } = await response.json();
return url;
}
Deprecated since v1.8 — This option is no longer supported and will be ignored.
Override document content with a JSON schema. Used to load documents from a previously exported JSON representation instead of a DOCX file.jsonOverride: { type: 'doc', content: [...] }
uiDisplayFallbackFont
string
default:"'Arial, Helvetica, sans-serif'"
Font family used for all SuperDoc UI elements (toolbar, comments, etc.)
suppressDefaultDocxStyles
Prevent default DOCX styles from being applied
Disable custom context menus
Content Security Policy nonce
Event handlers
All handlers are optional functions in the configuration:
Called when SuperDoc is readyonReady: ({ superdoc }) => {
console.log('Ready');
}
Called before an editor is created
Called when editor is createdonEditorCreate: ({ editor }) => {
editor.focus();
}
Called on content changesonEditorUpdate: ({ editor }) => {
autoSave(editor.getJSON());
}
Called when the comments sidebar is toggled
Called when an error occursonException: ({ error }) => {
console.error('SuperDoc error:', error);
}
See Events for complete list.