> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superdoc.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# React Integration

SuperDoc provides `@superdoc-dev/react`: a first-party wrapper with lifecycle management, SSR safety, and React Strict Mode compatibility.

## Install

```bash theme={null}
npm install superdoc@1 @superdoc-dev/react@1 @superdoc-dev/fonts
```

> [!NOTE]
>
> `superdoc` is included as a dependency: no need to install it separately.

## Quick start

```jsx theme={null}
import { SuperDocEditor } from '@superdoc-dev/react';
import { superdocFonts } from '@superdoc-dev/fonts';
import '@superdoc-dev/react/style.css';

function App() {
  return (
    <SuperDocEditor
      document={file}
      fonts={superdocFonts}
      documentMode="editing"
      onReady={() => console.log('Editor ready!')}
    />
  );
}
```

## Core concepts

### Document modes

| Mode | Description |
| - | - |
| `editing` | Full editing capabilities |
| `viewing` | Read-only presentation |
| `suggesting` | Track changes mode |

```jsx theme={null}
<SuperDocEditor document={file} documentMode="editing" />
```

### User roles

| Role | Can Edit | Can Suggest | Can View |
| - | - | - | - |
| `editor` | Yes | Yes | Yes |
| `suggester` | No | Yes | Yes |
| `viewer` | No | No | Yes |

```jsx theme={null}
<SuperDocEditor document={file} role="editor" />
```

### Responsive zoom

Pass `zoom` with `mode: 'fit-width'` to keep the document fitted to its container as it resizes. SuperDoc observes the container for you; no resize listeners needed. Calling `setZoom()` (or the user picking a percentage in the toolbar) switches back to manual mode.

```jsx theme={null}
<SuperDocEditor
  document={file}
  zoom={{
    mode: 'fit-width',
    fitWidth: { min: 35, max: 100, padding: 24 },
  }}
  onZoomChange={({ zoom, mode }) => console.log(`Zoom: ${zoom}% (${mode})`)}
/>
```

For custom behavior, listen to `onViewportChange` instead and apply your own zoom with `getInstance().setZoom()`. See [zoom configuration](https://docs.superdoc.dev/editor/superdoc/configuration.md#param-zoom).

## Handle file uploads

```jsx theme={null}
import { useState } from 'react';
import { SuperDocEditor } from '@superdoc-dev/react';
import '@superdoc-dev/react/style.css';

function FileEditor() {
  const [file, setFile] = useState(null);

  const handleFileChange = (e) => {
    const selected = e.target.files?.[0];
    if (selected) setFile(selected);
  };

  return (
    <div>
      <input type="file" accept=".docx" onChange={handleFileChange} />
      {file && (
        <SuperDocEditor
          document={file}
          user={{ name: 'User', email: 'user@company.com' }}
        />
      )}
    </div>
  );
}
```

## Next steps

> [card] [React API Reference](https://docs.superdoc.dev/editor/react/overview.md)
>
> Props, ref API, TypeScript types, and patterns

> [card] [Custom UI](https://docs.superdoc.dev/editor/custom-ui/overview.md)
>
> Build custom toolbar, comments sidebar, and review panel with typed React hooks

> [card] [Configuration](https://docs.superdoc.dev/editor/superdoc/configuration.md)
>
> Full SuperDoc configuration options

> [card] [Collaboration](https://docs.superdoc.dev/editor/collaboration/overview.md)
>
> Real-time collaboration setup

> [card] [React Example](https://go.superdoc.dev/react)
>
> React + TypeScript example

> [card] [Next.js Example](https://go.superdoc.dev/nextjs)
>
> Next.js SSR integration


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.