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

# How do I show a Word (DOCX) file read-only in React?

> Render DocondaEditor with readOnly: the Word file shows on your site with no toolbars and no editing, and users can still read, select and copy.

Render Doconda's editor plugin (`@doconda/editor`) with `readOnly`: `<DocondaEditor src={url} readOnly />`. The `.docx`
shows inside your site with its styles, tables, images and comments, with no toolbars and nothing editable. The same
component shows `.pptx` and `.xlsx`, and the file opens in the user's browser: it isn't uploaded anywhere to be shown.

## Steps

1. Get the plugin in the dashboard (**Editor**), with a 7-day free trial. See
   [Licence and domains](https://docs.doconda.com/editor/license.md).
2. Install it with the command the dashboard gives you. It needs React 19 or later:

```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
# .npmrc with the registry and token from the dashboard (Editor)
npm install @doconda/editor
```

3. Render the viewer in a container with a height, with `readOnly`:

```tsx theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
import { DocondaEditor } from "@doconda/editor"

export function View({ url }: { url: string }) {
  return (
    <div style={{ height: 700, display: "flex" }}>
      <DocondaEditor src={url} licenseKey="ek_eu_…" readOnly className="flex-1" />
    </div>
  )
}
```

`src` is a `.docx` the browser can download: from your site, or from a server that allows it with CORS. If the link
needs authentication, `requestInit` is passed as is to `fetch`:

```tsx theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
<DocondaEditor
  src="/api/contracts/42.docx"
  requestInit={{ headers: { Authorization: `Bearer ${token}` } }}
  licenseKey="ek_eu_…"
  readOnly
/>
```

## What read-only mode does

* Nothing can change the document: not typing, pasting, dragging or keyboard shortcuts.
* The toolbar, the second toolbar and the AI assistant disappear, and no recovery copy is kept.
* Users can still read, select and copy text, move between pages, slides and sheets, and present.

## Switch from viewer to editor without reloading

`readOnly` can change at any time, without reopening the file:

```tsx theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
const [viewOnly, setViewOnly] = useState(true)

<button onClick={() => setViewOnly(!viewOnly)}>{viewOnly ? "Edit" : "Done"}</button>
<DocondaEditor src={url} licenseKey="ek_eu_…" readOnly={viewOnly} />
```

## FAQ

> [accordion] Are comments and formatting shown?
>
> Yes. Read-only removes editing, not content: styles, tables, images and comments all show.

> [accordion] Can I open a file I already have in memory?
>
> Yes. Pass it in `file` instead of `src`, as a `File`, `Blob`, `ArrayBuffer` or `Uint8Array`, with its name in
> `fileName`.

> [accordion] Can I show a spinner while it opens?
>
> Yes. Put your spinner over the editor and remove it in `onReady`, which fires when the file has opened.

> [accordion] Where does it work?
>
> On your licence's domains (up to 5, https only), and always on `localhost` for development. See
> [Licence and domains](https://docs.doconda.com/editor/license.md#domains).

## Related

* [Customize: read-only](https://docs.doconda.com/editor/customize.md#read-only).
* [How do I add a Word (DOCX) editor to a React app?](https://docs.doconda.com/answers/docx-editor-react.md)


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