Skip to Content
OpenPreview

Introduction

OpenPreview is a React component that opens Word, Excel, PowerPoint, PDF and dozens of other file types in the browser, with no server and no uploads.

OpenPreview shows documents inside your React app. Give it a file, bytes or a URL and it works out what the file is from its contents, then draws it with a renderer built for that format.

Live: report.docx rendered by the library in this page.Open in the playground

What you get

  • One component for every file. <DocViewer source={file} /> handles Word, Excel, PowerPoint, PDF, OpenDocument, CSV, Markdown, code, images, email, ZIP archives and more. Each renderer is its own lazy chunk, so an app that only ever opens PDFs never downloads the spreadsheet code.
  • Files stay on the device. Parsing and drawing happen in the reader's browser. Nothing is sent to a conversion service, so it suits contracts, payslips, medical records and anything else under privacy rules.
  • A complete viewer. Toolbar, search, thumbnails and outline, zoom, rotation, printing, full screen, keyboard shortcuts, translations, right-to-left UI and screen-reader support are built in.
  • Your own UI when you want it. The headless hooks expose everything the stock viewer does, so you can build a toolbar or a whole layout that matches your design system.
  • Large files. Parsing runs in Web Workers, and long PDFs, huge sheets, CSVs and logs only draw what is on screen.

Packages

PackageWhat it is
@openpreview/reactThe <DocViewer> component, hooks and renderers. This is the one you install.
@openpreview/coreFramework-agnostic detection, loading and parsing. Safe to run in a Web Worker or Node. Installed with the React package.

Next steps

On this page