
Research
2025 Report: Destructive Malware in Open Source Packages
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.
react-doc-viewer
Advanced tools
Document viewer for react. Renders online/local documents. Plugins for new document renderers.
| MIME Type | Available |
|---|---|
| application/pdf | ✓ |
| image/png | ✓ |
| image/jpg, image/jpeg | ✓ |
npm i react-doc-viewer
# or
yarn add react-doc-viewer
DocViewer requires at least an array of document objects to function. Each document object must have a uri to a file, either a url that returns a file or a local file.
import DocViewer from "react-doc-viewer";
function App() {
const docs = [
{ uri: "https://url-to-my-pdf.pdf" },
{ uri: require("./example-files/pdf.pdf") }, // Local File
];
return <DocViewer documents={docs} />;
}
You can provide a theme object with one or all of the available properties.
<DocViewer
documents={docs}
theme={{
primary: "#5296d8",
secondary: "#ffffff",
tertiary: "#5296d899",
text_primary: "#ffffff",
text_secondary: "#5296d8",
text_tertiary: "#00000099",
disableThemeScrollbar: false,
}}
/>
Any styling applied to the <DocViewer> component, is directly applied to the main div container.
<DocViewer documents={docs} className="my-doc-viewer-style" />
<DocViewer documents={docs} style={{width: 500, height: 500}} />
import styled from "styled-components";
//...
<MyDocViewer documents={docs}/>
//...
const MyDocViewer = styled(DocViewer`
border-radius: 10px;
`
You can provide a config object, which configures parts of the component as required.
<DocViewer documents={docs} config={{
header: {
disableHeader: false,
disableFileName: false
}
}} />
Create a new folder inside src/plugins.
e.g.
src/plugins/jpg
Inside this folder, create a Renderer React Typescript file.
e.g.
JPGRenderer.tsx
Inside JPGRenderer, export a functional component of type DocRenderer
import React from "react";
import { useRecoilValue } from "recoil";
import styled from "styled-components";
import DocViewerState from "../../state";
import { DocRenderer } from "../../types";
import linkRenderResponder from "../../utils/linkRenderResponder";
// Be sure that Renderer correctly uses type DocRenderer
const JPGRenderer: DocRenderer = () => {
// Fetch the currentDocument loaded from main component state
const currentDocument = useRecoilValue(DocViewerState.currentDocument);
if (!currentDocument) return null;
return (
<Container id="jpg-renderer">
<Img id="jpg-img" src={currentDocument.base64Data} />
</Container>
);
};
export default JPGRenderer;
// List the MIME types that this renderer will respond to
JPGRenderer.fileTypes = ["image/jpg", "image/jpeg"];
// If you have more than one renderer for the same MIME type, use priority. 1 is more preferable.
JPGRenderer.priority = 1;
// Add the renderer to an event listener for 'request-document-renderer' from "alcumus-local-events"
linkRenderResponder(JPGRenderer);
If you are creating a renderer for a new MIME type, also update the following files.
Update src/plugins/index.ts with a direct import to your new renderer file.
This ensures that the linked event listener is running from the start of component use.
import "./jpg/JPGRenderer";
Update src/types/index.ts with your new MIME type.
This should match the array from JPGRenderer.filetypes.
export type FileType =
| "application/pdf"
| "image/png"
| "image/jpg"
| "image/jpeg";
DocViewer props| name | type |
|---|---|
| documents | IDocument[] |
| className? | string |
| style? | React.CSSProperties |
| config? | IConfig |
| theme? | ITheme |
IDocument| name | type |
|---|---|
| uri | string |
| fileType? | FileType - Used Internally |
| base64Data? | string - Used Internally |
IConfig| name | type |
|---|---|
| header? | IHeaderConfig |
IHeaderConfig| name | type |
|---|---|
| disableHeader? | boolean |
| disableFileName? | boolean |
ITheme| name | type |
|---|---|
| primary? | string |
| secondary? | string |
| tertiary? | string |
| text_primary? | string |
| text_secondary? | string |
| text_tertiary? | string |
| disableThemeScrollbar? | boolean |
DocRenderer| name | type |
|---|---|
| fileTypes | FileType[] |
| priority | number |
npm i && npm run start
FAQs
Document viewer for react. Renders online/local documents.
The npm package react-doc-viewer receives a total of 8,658 weekly downloads. As such, react-doc-viewer popularity was classified as popular.
We found that react-doc-viewer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.

Research
/Security News
A five-month operation turned 27 npm packages into durable hosting for browser-run lures that mimic document-sharing portals and Microsoft sign-in, targeting 25 organizations across manufacturing, industrial automation, plastics, and healthcare for credential theft.